Write a program that takes a 3 digit number n and finds out
whether the number 2^n + 1 is prime, or if it is not prime
find out its factors
Answer Posted / nitin garg
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
int num,i,sum=1,flag=0;
printf("enter three digit no
");
scanf("%d",&num);
for(i=1;i<=num;i++)
{
sum=sum*2;
}
sum++;
printf("
%d",sum);
for(i=2;i<sum/2;i++)
{
if(sum%i==0)
flag=1;
}
if(flag==0)
printf("
number is prime");
printf("
factor is below:
");
for(i=1;i<=sum;i++)
{
if(sum%i==0)
printf("%d ",i);
}
getch();
return 0;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Using which language Test cases are added in .ptu file of RTRT unit testing???
How do you redirect a standard stream?
What is function what are the types of function?
What is a loop?
What is the use of a ‘ ’ character?
Explain how can you tell whether two strings are the same?
Write a program to generate the Fibinocci Series
Write the control statements in C language
main() { printf("hello"); fork(); }
What is extern variable in c with example?
How to set file pointer to beginning c?
What is meant by high-order and low-order bytes?
What does it mean when a pointer is used in an if statement?
What are the features of c language?
What is the size of empty structure in c?