Goldbach's Conjecture
Description:
Goldbach's conjecture is amongst the oldest and well-known unsolved mathematical problems out there. In correspondence with Leonhard Euler in 1742, German mathematician Christian Goldbach made a conjecture stating that:
"Every even integer greater than 2 can be written as the sum of two primes"
which is known today as the (strong) Goldbach's conjecture.
Even though it's been thoroughly tested and analyzed and seems to be true, it hasn't been proved yet (thus, remaining a conjecture.)
Your task is to implement the function in the starter code, taking into account the following:
- If the argument isn't even and greater than two, return an empty array/tuple.
- For arguments even and greater than two, return a two-element array/tuple with two prime numbers whose sum is the given input.
- The two prime numbers must be the farthest ones (the ones with the greatest difference)
- The first prime number must be the smallest one.
A few sample test cases:
checkGoldbach(2)
/check_goldbach(2)
should return []
checkGoldbach(5)
/check_goldbach(5)
should return []
checkGoldbach(4)
/check_goldbach(4)
should return [2, 2]
checkGoldbach(6)
/check_goldbach(6)
should return [3, 3]
checkGoldbach(14)
/check_goldbach(14)
should return [3, 11]
Similar Kata:
Stats:
Created | May 20, 2014 |
Published | May 20, 2014 |
Warriors Trained | 1184 |
Total Skips | 80 |
Total Code Submissions | 3022 |
Total Times Completed | 515 |
JavaScript Completions | 180 |
PHP Completions | 46 |
Ruby Completions | 45 |
Elixir Completions | 17 |
Python Completions | 218 |
Go Completions | 13 |
Rust Completions | 17 |
D Completions | 4 |
C Completions | 18 |
Haskell Completions | 9 |
Total Stars | 34 |
% of votes with a positive feedback rating | 94% of 151 |
Total "Very Satisfied" Votes | 135 |
Total "Somewhat Satisfied" Votes | 13 |
Total "Not Satisfied" Votes | 3 |
Total Rank Assessments | 9 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 7 kyu |