#include<stdio.h>
void main()
{
int n,m,sum=0,a;
int i;
int count;
int j;
printf("Enter a no");
scanf("%d",&n);
m=n;
for(i=2;i<=n/2;i++)
{
a=0;
if(n%i==0)
{
count=0;
for(j=2;j<=i/2;j++)
{
if(i%j==0)
{
count++;
break;
}
}
if(count==0)
{
printf("Prime factor is %d \n",i);
}
}
}
}
output
Enter a no 50
Prime factor is 2
Prime factor is 5
void main()
{
int n,m,sum=0,a;
int i;
int count;
int j;
printf("Enter a no");
scanf("%d",&n);
m=n;
for(i=2;i<=n/2;i++)
{
a=0;
if(n%i==0)
{
count=0;
for(j=2;j<=i/2;j++)
{
if(i%j==0)
{
count++;
break;
}
}
if(count==0)
{
printf("Prime factor is %d \n",i);
}
}
}
}
output
Enter a no 50
Prime factor is 2
Prime factor is 5
No comments:
Post a Comment