+ 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.
3 Respostas
+ 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
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.
0
Limit is the "int limit" which is 2^31-1. I googled it but they are a bit complicated. Still, thanks.