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
What is the type of lambda expression?
What is the difference between the final method and abstract method?
Define nashorn in java8.
Is c better than java?
When will we prefer to use set and list in java and why?
Where is stringbuffer stored?
What are the methods to rectify ambiguities in the interfaces in JAVA?
What is the core java?
What are methods of a class?
What is the meaning of find and replace?
Difference between string, stringbuffer and stringbuilder?
What is Mutex (Mutual Exclusion Object) ?
What’s the difference between applets and standalone program?
How do you pass by reference?
What is public/private protected in java?