Skip to content

Instantly share code, notes, and snippets.

@pokutuna
Created September 12, 2012 18:48
Show Gist options
  • Save pokutuna/3709013 to your computer and use it in GitHub Desktop.
Save pokutuna/3709013 to your computer and use it in GitHub Desktop.
def consistsOfSameNumber(num: Int): Boolean = {
val sorted = num.toString.sortWith(_ < _)
List(2, 3, 4, 5, 6).map(num * _).forall(_.toString.sortWith(_ < _) == sorted)
}
println(Stream.from(100000).find(consistsOfSameNumber).get) // => 142857
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment