/*Prime factors for a number using c*/

# include

# include

int main()

{

int num,i=1,j,k;

//clrscr();

printf(“\nEnter a number:”);/* enter a positive integer */ scanf(“%d”,&num); while(i<=num) { k=0; if(num%i==0) // checks for factor { j=1; while(j<=i) { if(i%j==0) { k++; } j++; } if(k==2) /* checks for prime factor */

printf(“\n%d is a prime factor”,i);

}

i++;

}

getch();

}

OUTPUT for Prime Factors of a Given Numeber:

Enter a number:48

2 is a prime factor

3 is a prime factor