Problem 45. Make a Palindrome Number
Some numbers like 323 are palindromes. Other numbers like 124 are not. But look what happens when we add that number to a reversed copy of itself.
124
+ 421
----
545Let's try another.
150
+ 051
----
201No, that didn't work, but what if we keep going?
201
+ 102
----
303There, it became a palindrome again. Given a, return b = find_palindrome(a) such that b is the palindrome number that eventually results from repeated reversals and additions of a.
Example:
Input a = 150 Output b is 303
Solution Stats
Problem Comments
-
4 Comments
Why is seqreverse command not allowed to work?
That function is in the Bioinformatics Toolbox (http://www.mathworks.com/help/bioinfo/ref/seqreverse.html). Cody permits only MATLAB functions.
Many commands I thought would work ,didn't .... This problem helps in understanding the limits of the commands
Can every number be used to find a palindrome? I've tried 196, and it seems to run on an infinite loop.
Solution Comments
Show commentsProblem Recent Solvers2444
Suggested Problems
-
Find all elements less than 0 or greater than 10 and replace them with NaN
15730 Solvers
-
Back to basics 25 - Valid variable names
332 Solvers
-
Getting the indices from a vector
11303 Solvers
-
Generate a random matrix A of (1,-1)
376 Solvers
-
Who has power to do everything in this world?
475 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!