Given an integer N the task is to create a string out of it by repeating the number such that the length of the resultant string is equal to the sum of the digits in the original number.
For eg: If the number is 61 and the sum of the digits is 6 + 1 = 7 so the string generated after repeating 61 will be of 7 length i.e. 6161616.
Input: N = 10101
Length of the string is given by sum of the digits i.e. 1 + 0 + 1 + 0 + 1 = 3.
So the resultant string is “101” which is a palindrome.
Input: N = 123
Length of the string will be 1 + 2 3 = 6.
So the resultant string is “123123” which is not a palindrome.
- Find the sum of the digits of N and repeat the number till the length of the string becomes equal to this sum.
- Now check if the resultant string is a palindrome or not.
- If it is a palindrome then print Yes.
- Else print No.
Below is the implementation of the above approach:
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Check if a number is Palindrome
- Check if a number is Palindrome in PL/SQL
- Program to check the number is Palindrome or not
- Check if number is palindrome or not in Octal
- Bash program to check if the Number is a Palindrome
- To check a number is palindrome or not without using any extra space
- Recursive program to check if number is palindrome or not
- Check whether the given floating point number is a palindrome
- Check if a number with even number of digits is palindrome or not
- Check if actual binary representation of a number is palindrome
- Check if string remains palindrome after removing given number of characters
- Check whether the string S1 can be made equal to S2 with the given operation
- Check if the sum of digits of N is palindrome
- Check if all elements of the array are palindrome or not
- Check if any anagram of a string is palindrome or not
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.