Last active
August 16, 2021 13:23
-
-
Save arturjnt/283af52f0cd978fd5955f7dd9dd497c1 to your computer and use it in GitHub Desktop.
If you add a number and it's reverse, it'll will always finish as a palindrome... except 196
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Don't try 196 | |
// https://www.youtube.com/watch?v=7RSqBuZzthk | |
let number = 296; | |
let isPalindrome = false; | |
reverseNum = (number) => Number(number.toString().split('').reverse().join('')); | |
while (!isPalindrome) { | |
number += reverseNum(number); | |
isPalindrome = (number === reverseNum(number)); | |
} | |
console.log(number); // i.e. 296 + 692 = 988 + 889 = 1877 ... = 881188 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment