Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 / sumitgaur2010

#include<iostream>
#include<conio.h>
#include<math.h>
using namespace std;
int main()
{
int i,n,num,p=1;
cout<<"enter the number";
cin>>n;
num=pow(2,n)+1;
for(i=2;i<num/2;i++)
{
if(num%i==0)
{
p=0;
break;
}
}
if(p==1)
cout<<"prime";
else if(p==0)
{
cout<<"factors are";
for(i=2;i<num/2;i++)
if(num%i==0)
cout<<i<<",";
}
getch();
}

Is This Answer Correct ?    30 Yes 19 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

develop a program to calculate and print body mass index for 200 employees

2703


write a function that reverse the elements of an array in place.The function must accept only one pointer value and return void.

4647


write a program that can LOCATE and INSERT elements in array using c++ programming languages.

4099


Implement a command console for changing settings on a particular object. The command console should allow you to enter a string and will return the response (very similar to a terminal session). The commands are as follows: SET propertyname=newvalue will change the target object’s member named “propertyname” to have a value equal to “newvalue”. If the input value is incompatible (i.e. an int being set to a string), print out an appropriate error message. GET propertyname will print out the current value of the target object’s member named “propertyname”. GET * will print out a list of all target object members and their current values. The system should be extensible for future commands and should accept an arbitrary object, such that another developer could insert another object into the system and rely on the command console to get and set the properties correctly.

4000


Write a C/C++ program that connects to a MySQL server and displays the global TIMEZONE.

5174


i don't know about working of nested for loop can any one help me

2350


write a function that allocates memory for a single data type passed as a parameter.the function uses the new operator and return a pointer to the allocated memory.the function must catch and handle any exception during allocation

2952


write a program to perform generic sort in arrays?

3119


write a program that prompt the user to enter his height and weight,then calculate the body mass index and show the algorithm used

4913


write a program to calculate the amount of investment after a period n years if the principal investors was p and interest is calculated using compound interest,formular=a=p(1+r)^n

2924


create a stucture student containing field for roll no,class,year and marks.create 10 student annd store them in a file

2768


A suduco given & u hv 2 check if it is incomplete(blanks left),or correct or incorrect

2939


Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.

2570


How to Split Strings with Regex in Managed C++ Applications?

3748


what mean void creat_object?in public class in this code class A{ public: int x; A(){ cout << endl<< "Constructor A";} ~A(){ cout << endl<< "Destructor A, x is\t"<< x;} }; void create_object(); void main() { A a; a.x=10; { A c; c.x=20; } create_object(); } void create_object() { A b; b.x=30; }

2668