Be the first user to complete this post

  • 0
Add to List
Beginner

122. Goldbach's Conjecture

Goldbach's conjecture - Every even integer greater than 2 can be represented as the sum of two primes numbers.

Example:

Given Number : 200

Prime Numbers are 3 197
Prime Numbers are 7 193
Prime Numbers are 19 181
Prime Numbers are 37 163
Prime Numbers are 43 157
Prime Numbers are 61 139
Prime Numbers are 73 127
Prime Numbers are 97 103

Approach:

  • Check if the number is not even then return it.
  • Check if the number is less than 2 then return.
  • Navigate i, from 3 to number check if i and (x-i) is prime, if yes, Print it
 

Output:

Output :
Prime Numbers are 3 97
Prime Numbers are 11 89
Prime Numbers are 17 83
Prime Numbers are 29 71
Prime Numbers are 41 59
Prime Numbers are 47 53