Prime factors of a number in C 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&lt;stdio.h&gt;
void pf(long);
void main()
{
    printf("Enter a number: ");
    scanf("%ld",&amp;n);
    pf(n);
}
void pf(long n)
{
    long i,x;
    while(n%2==0)
    {
        printf("2\n");
        n=n/2;
    }
    x=3;
    while(x&lt;=n)
    {
        for(i=2;i&lt;x;i++)
        {
            if(x%i==0)
            {
                goto abc;
            }
        }
        while(n%x==0)
        {
            printf("%ld\n",x);
            n=n/x;
        }
        abc:
            x=x+2;
    }
}
Can you describe a bit your algorithm ? There is no comments in your code and it is not straightforward (because no comments is acceptable when the code is easy to read, but not in this case). 
A few things that you should consider :


the use of global variables is here totally inapropriate, n should not be global and your function pf should take an argument (and should also return an array of the prime factors found, if you need them)
the while(1) is useless the two times you used it. It is commonly bad practise to use this, and especially when there is only one condition in the loop and when you exit the loop when the condition is not true. You should use while(condition) instead
Name correctly your variables ! What are i, x, n ? It improvs readability by a lot with absolutely no cost, so you should do it
I also don't see why you need the goto. Again it makes your code hard to read for no obvious good reason.
If n is a positive number, you should use an unsigned type. Since you want to be able to process 10 digits numbers, I would recommend using unsigned long long


Aside from that, I think it's mostly the algorithm that you use that is ineffective, which is why you should explain what you tried to do.