module Infinite
, fizzBuzz
— Define the infinite list of the collatz conjecture
Copyright By PowCoder代写 加微信 powcoder
— Rules: given argument n
— n is even -> n/2
— n is odd -> n * 3 + 1
— e.g. collatz 5 = [5, 16, 8, 4, 2, 1, 4, 2, 1 ..]
— Hint: Integer division is done by `div`, not /
collatz :: Integral a => a -> [a]
collatz = undefined
— Define the infinite list of FizzBuzz
— “FizzBuzz” if multiple of 3 and 5
— “Fizz” if multiple of 3
— “Buzz” if multiple of 5
— else just the number as string
— e.g. fizzBuzz = [1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13 14, FizzBuzz]
— Hint: use `show` to make an int into a string
— use `mod` for module operation
fizzBuzz :: [String]
fizzBuzz = undefined
— Define the infinite list of Fibonacci in O(n)
— The first two numbers in the sequence are 0 and 1 respectively
— All other numbers are the sum of their previous two numbers
— e.g. fib = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ..]
— Hint: You can define this using `zipWith`
fib :: Num a => [a]
fib = undefined
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com