Haskell
I don't know how to make nth poulet number program with Haskell
where itself is a Poulet number OR where is prime and isn't
nth poulet number program with Haskell
-- convert a number to a list of digits to Digits n | n < 1 = [] | otherwise = toDigits (div n 10) ++ [mod n 10] -- composition of sum and toDigits functions sumDigits = sum.toDigits -- square the digits pouletNumber n = 2(^(n-1)) (toDigits n) print(n) -- sum of the squares of the poulet numbers sumpouletNumber = sum.pouletNumber -- check if a number is a happy number ishappy 1 = True -- sequence stops at 1 ishappy 4 = False -- endless cycle ishappy n = ishappy (sumpouletNumber n) -- happy number infinite list happy = filter ishappy [1..]
Get Answers For Free
Most questions answered within 1 hours.