Challenge 🏆🏆 Represent a composite number as a sum of two prime numbers. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

Challenge 🏆🏆 Represent a composite number as a sum of two prime numbers.

Its a proof that any composite number can be represented as the sum of two prime number. eg. 8 = 5+3; 22 = 19 + 3; or 17 + 5; Your program should find all the pairs of prime numbers whose sum is equal to n where n is any composite number.

7th Jan 2018, 7:55 PM
Faizan Hussain
Faizan Hussain - avatar
9 Answers
+ 27
https://code.sololearn.com/czTIFjtzn23y/?ref=app
8th Jan 2018, 10:35 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 13
Not every composite number is the sum of two primes. Counterexamples: Every odd composite number n, such that n-2 is not prime (27, 35, 51...). We actually don't know whether every even number bigger than two is the sum of two primes. Every number we looked at has that property, but that does not constitute a proof, as we only checked for a finite subset of an infinite set of numbers. https://en.m.wikipedia.org/wiki/Goldbach%27s_conjecture
7th Jan 2018, 11:36 PM
Tob
Tob - avatar
8th Jan 2018, 9:44 AM
abdulazizumarovich
abdulazizumarovich - avatar
+ 3
https://code.sololearn.com/crMUlLUT6Uqw/?ref=app
7th Jan 2018, 8:15 PM
Dejan Francuz🥇
Dejan Francuz🥇 - avatar
8th Jan 2018, 8:32 PM
VcC
VcC - avatar
+ 3
here's the most straightforward version I could make in c++ : https://code.sololearn.com/c9ooluWHmO42/?ref=app
9th Jan 2018, 7:10 AM
Kalistic Modiani
Kalistic Modiani - avatar
+ 2
https://code.sololearn.com/clD3j87zJXPw/?ref=app
11th Jan 2018, 8:44 AM
Arun
- 2
11 + 11 is also equal to 22
11th Jan 2018, 8:48 PM
Arun