Question

Haskell I don't know how to make nth poulet number program with Haskell

Haskell

I don't know how to make nth poulet number program with Haskell

Homework Answers

Answer #1

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..]
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a .asm program that computes the Nth Fibonacci number. N will be provided in R0...
Write a .asm program that computes the Nth Fibonacci number. N will be provided in R0 and the output should be in R1
If I know the state of a system at two different times, but don't know how...
If I know the state of a system at two different times, but don't know how much time has passed between them, it makes more sense to use: A The momentum principle B Conservation of energy
How to find laplace of .... L [t3 sint] ? usually I don't know how to...
How to find laplace of .... L [t3 sint] ? usually I don't know how to deal with to variable inside brakets
Use a loop invariant to prove that the following program segment for computing the nth power,...
Use a loop invariant to prove that the following program segment for computing the nth power, where n is a positive integer, of a real number x is correct. power := 1 i := 1 while i <= n power := power*x i := i+1
I have a recursive Tower of Hanoi program but don't know how to include the count...
I have a recursive Tower of Hanoi program but don't know how to include the count variable. Could you tell me how? Main.java import java.io.*; import java.util.List; public class Main { //int count = 0; /**There is a stack of N disks on the first of three poles (call them A, B and C) and your job is to move the disks from pole A to pole B without ever putting a larger disk on top of a smaller disk.*/...
I have the equation dP/dt = k(M-P), and I don't know how to graph it in...
I have the equation dP/dt = k(M-P), and I don't know how to graph it in Mathematica where it's dP/dt versus P.
We were given the answers for this question but I don't know how to get to...
We were given the answers for this question but I don't know how to get to those answers. Identify the p-block group to which X belongs: i) X2O3 ii) XO iii) X2O
In chemistry I'm having problems solving equilibrium problems because I don't know how to rearrange the...
In chemistry I'm having problems solving equilibrium problems because I don't know how to rearrange the equation: how do you reaarange this: given: kp = 0.997 0.997= [3.00]^2 [O2] / [0.520]^2 you need to find [O2]. I don't need you to actually solve this, just provide me with examples of how to set this up so I can solve for [O2] or if you have: k=[0.1-x]^2 [0.5-2x]^3 / [2.3-3x]^2
In Haskell How to write a function that receives a list and returns a list of...
In Haskell How to write a function that receives a list and returns a list of tuples that contains the character and number of occurrence on the list. for example: "Hello" -> [ ('H',1), ('e',1), ('l',2),('l',2),('o',1) ]
I don't know how to write (iii) and want to make sure my answer is right...
I don't know how to write (iii) and want to make sure my answer is right for (i) and (ii) A prize competition operates by a machine choosing randomly (no replacement) 3 balls from 18. There are 6 red balls, 6 blue balls and 6 green balls. And for each colour the balls are numbered 1,2,3,4,5,6. There are three ways you can win: (C) you have three balls the same colour; (T) you have “top scores” meaning that the three...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT