Hello, I came up with easy solution in C, loop and loop, level 3, 5th. If you find it easier, then replace the exesting one. :) My solution has one less integer and easier to understand. #include <stdio.h> for(i=2;i<num;i++) } You may further explain code with comments but i dont think there is need. Thanks.
int main()
{
int num,i,j;
printf("enter a number : ");
scanf("%d",&num);
{
if(num%i==0)//to check it is factor or not
{
for(j=2;(j<i)&&(i%j!=0);j++) //to check factor is prime or not
{
if(j==i-1)
{
printf("%d ",i);
}
}
}
return 0;
}