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
- 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
- AKS Primality Test
- Lucas Primality Test
- Primality Test | Set 2 (Fermat Method)
- Primality Test | Set 3 (Miller–Rabin)
- Vantieghems Theorem for Primality Test
- Implementation of Wilson Primality test
- Primality Test | Set 4 (Solovay-Strassen)
- 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
- Count of numbers between range having only non-zero digits whose sum of digits is N and number is divisible by M
- Minimum number of digits to be removed so that no two consecutive digits are same