, , - , , 52, .
, , , , , .
#include<stdio.h>
void main () {int i, j, b = 2, c; printf ("\ nEnter a compound number:"); scanf ("% d", & c); printf ("Factors:");
for(i=1; i<=c/2; i++)
{
if(c%i==0)
{
printf("%d ", i);
for(j=1; j<=i; j++) //since a numbr cand be divisible by a number greated than its half
{ if(i%j > 0)
b = i; //b stores the largest prime factor
if(b%3==0)
b = 3;
else if(b%2==0)
b=2;
else if(b%5==0)
b=5;
}
}
}
printf("%d\nLargest prime factor: %d\n", c, b);
}
source
share