Given a number a N and the task is to check weather the sum of absolute difference of adjacent digit is a prime or not.
Input: N = 142 Output: Prime Sum = |1-4| + |4-2| = 5 i.e. prime. Input: N = 347 Output: Not prime
Approach: Find the sum of absolute difference of adjacent digits and then check if that sum is prime or not.
Below is the implementation of the above approach:
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Check whether the sum of prime elements of the array is prime or not
- Absolute Difference between the Sum of Non-Prime numbers and Prime numbers of an Array
- Absolute difference between the Product of Non-Prime numbers and Prime numbers of an Array
- Absolute difference between the XOR of Non-Prime numbers and Prime numbers of an Array
- Check if sum of count of digits of array elements is Prime or not
- Check whether a number is circular prime or not
- C Program to Check Whether a Number is Prime or not
- Python program to check whether a number is Prime or not
- Check whether the given number is Wagstaff prime or not
- Check whether the given numbers are Cousin prime or not
- Check whether count of distinct characters in a string is Prime or not
- Check whether the frequencies of all the characters in a string are prime or not
- Check whether N is a Dihedral Prime Number or not
- Check whether a number is Good prime or not
- Print prime numbers with prime sum of digits in an array
- Sum of prime numbers without odd prime digits
- Count all prime numbers in a given range whose sum of digits is also prime
- Pair of prime numbers with a given sum and minimum absolute difference
- Count of numbers upto N digits formed using digits 0 to K-1 without any adjacent 0s
- Arrange first N natural numbers such that absolute difference between all adjacent elements > 1
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.