i made a recursive function to find the prime factors of a number but it has a bug which makes turbo c quit. please help
#include<stdio.h>
#include<conio.h>
int prime(int num);
int primefactor(int num,int i);
void main(void)
{
int num;
printf("Enter a number whose prime factors are to be calculated:");
scanf("%d",&num);
primefactor(num,i);
i=num
getch();
}
int primefactor(int num,int i)
{
if(i==2)
return 1;
if(num%i==0)
{
if(prime(num))
{
printf(",%d",num);
num=num/i;
i++;
}
}
i--;
primefactor(num,i);
return 0;
}
int prime(int num)
{
int i,flag;
for(i=2;i<num;i++)
{
if(num%i==0)
flag=0;
}
return flag; }