/*
** Free memory or garbage in recursion program
** Here, i have maked a simple recursion program. It's parametter is
** an integer called i.
** If i = 5 then return 1, else return i * Recursion(i+1). It is
** very simple, we will not say about the mean of this program.
** The more important, int Recursion function i created a j varible
** and when the program finished, i want to release memories pointed
** by pointer j. I don't know how. Can you help me.
** I want to know your idea and don't change my idea in this funny
** program.
** I think we always met this problem.
** Good luck to all of you !
*/
#include <stdio.h>
#include <malloc.h>

int Recursion( int* i)
{
if ( *i == 5 )
return 1;
else
{
int *j = 0;
j = (int*) malloc(sizeof(int));
*j = *i+1;
return (*i * Recursion( j ));
}
}
void main()
{

int i = 1;
int k = Recursion( &i );

printf("%d",k); // return 24


}