print asterisks to correspond to my program

Hey guys so i have to make two functions one recursion that ask the user to enter number of rows and i use recursion to tell him how many pins there are ex. user enters 5 there are 15 pins. I did this function now i need a function that prints an asterisk triangle for my recursion function so for 15 it should look like this
1
2
3
4
5
6
 
       *
      * *
     * * *
    * * * *
   * * * * *

i tried many times but can't make it descend like that i can only get like a right triangle any help would be appreciated it the hard part is that it goes with the users number so if they enter 3 for example it should be 3 rows.

1
2
3
4
5
6
7
8
9
10
11
12
int pins(int n){
	
	if(n==0){
	return 0;
	}
	else if (n==1){
	return 1;
	}
	else {
	return (n + pins(n-1)); 	
	}
	
There is few cases where recursion is ppropriate and this is not one of them.
You will be better to made your output function iterative. If you still want to use recursion, your recursive function will probabty have to take more than one parameter.
Topic archived. No new replies allowed.