I have to write a agenda to print the primary factor of the given number. Can anybody help me to write the program to print prime factor of given number?
Any help would be highly appreciated…
I have to write a agenda to print the primary factor of the given number. Can anybody help me to write the program to print prime factor of given number?
Any help would be highly appreciated…
1) try this
main()
{
int a,c=0,i,n;
printf("enter the number to be checked");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
a=n%i;
if(a=0)
{
c=c+1;
}
}
if (c=2)
{ printf("the given number is prime"); }
else
printf("the given number is not prime");
}
2) Try the given code below which is helpful for u.
void main()
{
int i,n;
printf("enter the number to be checked");
scanf("%d",&n);
for(i=2;i<=n;i++)
{
if(n%i==0)
printf("The number is prime number")
}
else
printf("the given number is not a prime number");
getch();
}
Bookmarks