HOW TO CALCULATE GOLDBACH'S CONJECTURE IN JAVA? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

HOW TO CALCULATE GOLDBACH'S CONJECTURE IN JAVA?

Hello guys, I need to code Goldbach's Conjecture in Java and I can only use the keywords that we've learnt so far. Those are int, double, string, etc. and for, while, if, else (e.g I can't use arrays to do this). Can you help me on it? Every little thing will help.

27th Feb 2017, 8:57 AM
Sefa Şenlik
Sefa Şenlik - avatar
3 Answers
+ 1
A Goldbach number is a positive even integer that can be expressed as the sum of two odd primes. Note: All even integer numbers greater than 4 are Goldbach numbers. Example: 6 = 3 + 3 10 = 3 + 7 10 = 5 + 5 Hence, 6 has one odd prime pair 3 and 3. Similarly, 10 has two odd prime pairs, i.e. 3, 7 and 5, 5. https://code.sololearn.com/cR0xdb49I36m/?ref=app
17th Jul 2019, 6:32 PM
Prantik Sarkar
Prantik Sarkar - avatar
0
Without arrays it would look.. weird. There must be some limits for your task, lets say input is a number up to 100 or something like that. Google "goldbachs conjecture java" instantly gives you a sample source code which you can modify to fullfill the requirements.
27th Feb 2017, 9:23 AM
Zilvinas Steckevicius
Zilvinas Steckevicius - avatar
0
Limit is the "int limit" which is 2^31-1. I googled it but they are a bit complicated. Still, thanks.
27th Feb 2017, 9:49 AM
Sefa Şenlik
Sefa Şenlik - avatar