//Program
# include <stdio.h>
void main()
{
int n,x;
printf("Enter the number for testing(prime or not):");
scanf("%d",&n);
for(x=2;x<n;x++)
{
if(n%x==0)
{
printf("%d is not a prime number",n);
exit(0);
}
}
printf("%d is a prime no",n);
}
// PRIME NUMBER SERIES
# include <stdio.h>
void main()
{
int i,j,lim,count=0;
printf("Enter the limit : ");
scanf("%d",&lim);
printf("Prime Numbers from 1 to %d are : \n",lim);
for(i=1;i<=lim;i++)
{
for(j=2;j<i;j++)
{
if(i%j==0)
{
count++;
break;
}
}
if(count==0 && i!=1)
printf("%d ", i);
count = 0;
}
return 0;
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.