1. ## Recursion...

Hello, I am still noob at programming
Our lesson is about recursion
I know about basic stuff about how to do the Fibonacci Sequence and factorial

However, our teacher has been making us to do complex stuff
like:

If N = 5:

12345
*123*
**1**

If N = 7:
1234567
*12345*
**123**
***1***

and

If N = 5:
12345
*2345
**345
***45
****5

2. See if you can do this with a loop. Then just about any loop can be converted into recursion if you pass enough of the variables as parameters. For the first 2 examples, you would pass the original value of N, and a current value that decrements by 2 on each recursion.

3. forum bug, I tried to edit reply and it made a second instance. Tried to delete the first, but that didn't work either, so I'm leaving both replies.

See if you can do this with a loop. Then just about any loop can be converted into recursion if you pass enough of the variables as parameters. For the first 2 examples, you would pass the original value of N, and a current value that decrements by 2 on each recursion.

4. something like this for the last one maybe

Code:
```#include<stdio.h>

void func(int n, int count){
if(count==n)
return;
int i;
for(i=1; i <= n; i++){
if(i<=count)
printf("*");
else
printf("%i", i);
}
printf("\n");
func(n, count+1);
}
int main(void){
func(5,0);
return 0;
}```

Popular pages Recent additions