C Program to Find Prime Factors of a Given Positive Number

/Prime factors for a number using c/



int main()
int num,i=1,j,k;
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);

OUTPUT for Prime Factors of a Given Numeber:

Enter a number:48

2 is a prime factor
3 is a prime factor

Leave a Reply

Your email address will not be published. Required fields are marked *