Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- numberToDigits :: Int -> [Int]
- numberToDigits 0 = []
- numberToDigits n = (mod n 10) : numberToDigits (div n 10)
- minDigit :: Int -> Int
- minDigit 0 = 0
- minDigit n = foldr1 min (numberToDigits n)
- digitsSum :: Int -> Int
- digitsSum 0 = 0
- digitsSum n = (mod n 10) + digitsSum (div n 10)
- digitsCount :: Int -> Int
- digitsCount 0 = 0
- digitsCount n = 1 + digitsCount (div n 10)
- digitsAvgF :: Int -> Float
- digitsAvgF num = (fromIntegral (digitsSum num)) / (fromIntegral (digitsCount num))
- digitsAvgI :: Int -> Int
- digitsAvgI num = div (digitsSum num) (digitsCount num)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement