Hi, I'm trying to use recursion (no loops) to print out descending odd, then ascending even squares less than a certain number.
For examples, squares(5) would print out: 25, 9, 1, 4, 16.
I'm not sure how I would alternate between even/odd, and would really appreciate some help with that.
Right now, I have it so that all squares are printed in descending order. All input is greatly appreciated!
You are almost done.
One Suggestion: why do you throw Exception from base condition, I do suggest you to just return.
Hint : even number * even number => even number ; odd number * odd number => odd number.
So, when you encounter even number dont print it instead put into a *X* datastructure. and print it later in base condition before return.