Monday, September 12, 2011

find the prime factor of the given number

find the prime factor of the given number */
#include<stdio.h>
#include<conio.h>
main()
{
    int i=2,j=0,k,n,arr[15];
    clrscr();
    printf("enter any integer greater than 1:");
    scanf("%d",&n);
    while(i<=n)
    {
        if(n%i==0)
        {
            do{
            arr[j]=i;
            n=n/i;
            j++;
            }while(n%i==0);
        }
        else
        i++;
    }
    printf("prime factors of the number are\n");
     /*    for(k=j-1;k>=0;k--)
    printf("%d\t",arr[k]);    */
    for(k=0;k<=j-1;k++)
    printf("%d\t",arr[k]);
    getch();
}


No comments:

Post a Comment

Popular 5 Posts Last 7 days