I have a program to write in which I need to create the following fractal pattern using recursion:

[img]http://img19.imageshack.us/img19/7456/73284540.png[/img]
^image link

My professor said two recursive calls are needed, and 2 parameters are also needed. One parameter indicates the indentation of the leftmost line, while the other indicates the number of stars in the largest line.

I really need help with this. I have no idea where and how to start this. And it is due this Monday.

You need two methods because there are two independent patterns in that picture. The first pattern is the one that looks like:

*
**
*

And the second pattern is the one that switches between printing 4 stars and 8 stars. All you need for the first method is something that prints the first pattern I showed you above. All you need for the second method (the one that switches between printing 4 stars and eight stars) is a counter. If the counter is a multiple of 2, you print eight stars. Otherwise, you print 4 stars.

Oh, and the recursion comes into play because after the first method prints its stars, it needs to call the second method to print its stars. The second method can then call the first method again. You need to also remember that you'll need some way to decide when to stop printing stars.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.