Created
July 19, 2016 20:24
-
-
Save jadlr/baa83a68c1c503ee1f3f646acbcf9e6f to your computer and use it in GitHub Desktop.
Repdigit sequence calculation in haskell
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
module Repdigit where | |
-- https://oeis.org/A010785 | |
repdigit :: Integer -> Integer | |
repdigit n = (n - 9 * floor ((fromInteger n - 1) / 9)) * (10 ^ floor ((fromInteger n + 8) / 9) - 1) `quot` 9 | |
repdigits :: [Integer] | |
repdigits = go 0 | |
where go n = repdigit n : go (n + 1) |
Author
jadlr
commented
Jul 19, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment