thinking more recursively, I changed the while(1) loop into another recursive call:
Code:
/*prime factor by recursion*/
#include<stdio.h>
int rec (int,int);
int rec1 (int, int); /* this semi colon is must*/
int main(void)
{
int n;
printf("Enter any positive integer for prime factorization ? ");
scanf("%d",&n);
rec(n,2);
return (0);
}
int rec(int n, int l)
{
n=rec1(n,l);
if (n>l)
rec(n,l+1);
return 0;
}
int rec1(int n, int l)
{
if (n%l==0)
{
printf("%d ",l);
n=n/l;
rec1(n,l);
}
return n;
return 0;
}
But the code is wrong answer for n=288
any help possible?