# Goldbach’s Weak Conjecture for Odd numbers

Given an odd number N, the task is to find if the number can be represented as the sum of 3 prime numbers.

Examples:

```Input: N = 7
Output: Yes
Explanation:
2 + 2 + 3 = 7

Input: N = 17
Output: Yes
Explanation:
2 + 2 + 13 = 17
```

## Recommended: Please try your approach on {IDE} first, before moving on to the solution.

Approach:
In number theory, Goldbach’s weak conjecture, also known as the odd Goldbach conjecture, the ternary Goldbach problem, or the 3-primes problem, states that Every odd number greater than 5 can be expressed as the sum of three primes. (A prime may be used more than once in the same sum.).

Below is the implementation of the above approach:

## C++

 `// C++ implementation of the approach ` `#include ` `using` `namespace` `std; ` ` `  `// if a number can  ` `// be represent as  ` `// as a sum of 3 prime ` `void` `check(``int` `n)  ` `{ ` `    ``if` `(n % 2 == 1 && n > 5)  ` `        ``cout << ``"Yes\n"``; ` `    ``else` `        ``cout << ``"No\n"``; ` `} ` `     `  `// Driver code ` `int` `main() ` `{ ` `    ``int` `a = 3; ` `    ``int` `b = 7; ` `    ``check(a); ` `    ``check(b); ` `    ``return` `0; ` `} ` ` `  `// This code is conributed by 29AjayKumar `

## Java

 `class` `GFG  ` `{ ` `    ``// Function to check  ` `    ``// if a number can  ` `    ``// be represent as  ` `    ``// as a sum of 3 prime ` ` `  `    ``static` `void` `check(``int` `n)  ` `    ``{ ` `        ``if` `(n % ``2` `== ``1` `&& n > ``5``)  ` `        ``{ ` `            ``System.out.println(``"YES"``); ` `        ``}  ` `        ``else`  `        ``{ ` `            ``System.out.println(``"NO"``); ` `        ``} ` `    ``} ` `     `  `    ``// Driver code ` `    ``public` `static` `void` `main(String[] args)  ` `    ``{ ` `        ``int` `a = ``3``; ` `        ``int` `b = ``7``; ` `        ``check(a); ` `        ``check(b); ` `    ``} ` `}  ` ` `  `// This code is contributed by PrinciRaj1992 `

## Python3

 `# Function to check  ` `# if a number can  ` `# be represent as  ` `# as a sum of 3 prime ` `def` `check(n): ` `  ``if` `n ``%` `2` `=``=` `1` `and` `n > ``5``: ` `    ``print``(``'YES'``) ` `  ``else``: ` `    ``print``(``'NO'``) ` ` `  `# Driver code ` `def` `main(): ` `  ``a ``=` `3` `  ``b ``=` `7` `  ``check(a) ` `  ``check(b) ` ` `  `main() `

## C#

 `using` `System; ` ` `  `class` `GFG  ` `{ ` `    ``// Function to check  ` `    ``// if a number can  ` `    ``// be represent as  ` `    ``// as a sum of 3 prime ` `    ``static` `void` `check(``int` `n)  ` `    ``{ ` `        ``if` `(n % 2 == 1 && n > 5)  ` `        ``{ ` `            ``Console.WriteLine(``"YES"``); ` `        ``}  ` `        ``else` `        ``{ ` `            ``Console.WriteLine(``"NO"``); ` `        ``} ` `    ``} ` `     `  `    ``// Driver code ` `    ``public` `static` `void` `Main(String[] args)  ` `    ``{ ` `        ``int` `a = 3; ` `        ``int` `b = 7; ` `        ``check(a); ` `        ``check(b); ` `    ``} ` `}  ` ` `  `// This code is contributed by PrinciRaj1992 `

Output:

```NO
YES
```

My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Improved By : princiraj1992, 29AjayKumar

3

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.