Question: Write a recursive method called writeSquares that accepts an integer parameter and prints the first squares separated by commas, with the odd squares in descending

Write a recursive method called writeSquares that accepts an integer parameter and prints the first squares separated by commas, with the odd squares in descending order followed by the even squares in ascending order. For example, writeSquares(8); prints the following output:

49, 25, 9, 1, 4, 16, 36, 64

A call of writeSquares(1); prints 1. The method should throw an IllegalArgumentException if it is passed a value less than 1.

Step by Step Solution

3.40 Rating (169 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public void writeSquares int n if n 1 thro... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Building Java Programs A Back to Basics Approach Questions!