The following is code on "prime factors of a number". Any suggestions to optimize the code? It runs for a pretty long time for inputs like 35068499. I also want the code to take 10 digit numbers as input.
#include<stdio.h>
void pf(long);
void main()
{
printf("Enter a number: ");
scanf("%ld",&n);
pf(n);
}
void pf(long n)
{
long i,x;
while(n%2==0)
{
printf("2\n");
n=n/2;
}
x=3;
while(x<=n)
{
for(i=2;i<x;i++)
{
if(x%i==0)
{
goto abc;
}
}
while(n%x==0)
{
printf("%ld\n",x);
n=n/x;
}
abc:
x=x+2;
}
}