java 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 / karuna

Mr Nithi U'r Wrong If it is 2^n-1
Then
2^n-1=2^n-1^n
(2^(n/2))^2-(1^(n/2))^2 [ like a^2 - b^2 ]
(2^(n/2)+1)*(2^(n/2)-1)) [ like (a+b) (a-b) ]

So factors is 2^(n/2)+1),2^(n/2)-1)
This also n is even and expect 2 .
2^n - 1 is not a prime.
n is odd and include 2 then
2^n - 1 is prime.

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are loops in java?

548


why we use merge option in hybernate pls give a ex snippet

1453


Does java return by reference?

531


Can we increase size of array?

562


How does finally block differ from finalize() method?

583






Can we use synchronized block for primitives?

602


What is %d in printf?

522


Explain the scope of a variable.

627


What are the two types of java?

515


Does list allow duplicates in java?

514


What is the use of java?

526


What are the different types of collections in java?

526


How to optimize the javac output?

594


What is a wrapper method?

531


What are exceptions

640