Created
January 10, 2014 16:55
-
-
Save kazoo04/8357994 to your computer and use it in GitHub Desktop.
Next Palindrome
This file contains hidden or 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
package io.github.kazoo04.palindrome | |
import scala.annotation.tailrec | |
object NextPalindrome { | |
@tailrec | |
def next(num: Int): Int = { | |
val n = num + 1 | |
if(n.toString == n.toString.reverse) { | |
return n | |
} | |
next(n) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment