Given an integer ‘n’, the task is to check whether the sum of digits at the odd positions (from right to left) is prime or not.
If it is prime then, print “YES” or “NO” otherwise.
Input: n = 123
As, 1 + 3 = 4 is not prime.
Input: n = 42
Since, 2 is a prime.
Approach: First, find the sum of the digits which are at odd positions i.e, 1, 3, 5, … (starting from right).
If the sum is prime then print ‘YES’ else print ‘NO’.
Below is the implementation of the above approach:
- Check whether product of digits at even places is divisible by sum of digits at odd place of a number
- Find the sum of digits of a number at even and odd places
- Check whether sum of digits at odd places of a number is divisible by K
- Check whether product of digits at even places of a number is divisible by K
- Check if product of digits of a number at even and odd places is equal
- AKS Primality Test
- Lucas Primality Test
- Implementation of Wilson Primality test
- Primality Test | Set 4 (Solovay-Strassen)
- Primality Test | Set 2 (Fermat Method)
- Primality Test | Set 3 (Miller–Rabin)
- Vantieghems Theorem for Primality Test
- Primality Test | Set 1 (Introduction and School Method)
- Primality Test | Set 5(Using Lucas-Lehmer Series)
- Total number of ways to place X and Y at n places such that no two X are together
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.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.