You are viewing a single comment's thread. Return to all comments →
Haskell
Function wwo -- "with or without"
module Main where vals :: Int -> Int -> [Int] vals n k = reverse $ takeWhile (<= n) [x ^ k | x <- [1 ..]] wwo :: Int -> [Int] -> Int wwo n xs | n == 0 = 1 | n < 0 = 0 | null xs = 0 | otherwise = wwo n (tail xs) + wwo (n - head xs) (tail xs) main :: IO () main = do n <- readLn :: IO Int k <- readLn :: IO Int print $ wwo n (vals n k)
Seems like cookies are disabled on this browser, please enable them to open this website
The Power Sum
You are viewing a single comment's thread. Return to all comments →
Haskell
Function wwo -- "with or without"