First of all, the title was inspired by the original paper of transformer model, Attention Is All You Need
I ever thought that i can getting rich easily just to solve an unsolved math problem, but after i surfing the internet with the keyword “Simplest unsolved math problem” I undo my intention because I am stupid in mathematics.
One of the problems that interests me is to try the "Goldbach Conjecture", it is very simple only integers greater than 2 can be added from 2 prime numbers. It's interesting for me not to answer, but to prove it using my computer science background.
Goldbach conjecture was first mentioned by Christian Goldbach in his letter to Euler in 1742. In his letter, Goldbach reported that even numbers greater than or equal to 4 could be written as the sum of two prime numbers, but he failed to prove the truth of his conjecture.
I proved by using the C + + programming language, this is more or less:
First I declare a function that returns a integer numbers.
int is_prime(int n){
int num = 1;
for (int i = 2; i < n/2; i++){
if((n%i) == 0){
return num-1;
}
}
return num;
}
The next step is create a procedure for the logic of this mathematical problem.
void solve(){
int number = 0;
int primes[100000] = {2};
int j = 0;
while(true){
std::cout<<"Input even number:";
std::cin>>number;
if(number > 2 && number % 2==0){
if(primes[j]<number){
for (int i = primes[j]+1; i < number; i++){
if(is_prime(i) == 1){
j++;
primes[j] = i;
}
}
}
for (int i = 0; i < j; i++){
for (int k = 0; k < j; k++){
if(primes[i] + primes[k] == number){
std::cout<<primes[i]<<" + "<<primes[k]<<" = "<<number<<std::endl;
break;
}
}
}
}
else{
std::cout<<"Input must a even numbers"<<std::endl;
}
}
}
The last step is just declared the procedure to main function.
int main(){
solve();
return 0;
}
Here is the output, let's say i entered the number 120.
Maybe you passed the incorrect grammar or tenses, i'm sorry, i'm bad in english :)
Reference
Wikipedia
Top comments (0)