sumaPotenciasDe2y3.hs

Anonymous
haskell
08/26/2024 7:11 PM
568 B
21
Indexable
esPotenciaDeX :: Int -> Int -> Bool
esPotenciaDeX x n
    | n <= 0        = False
    | n == 1        = True
    | mod n x /= 0  = False
    | otherwise     = esPotenciaDeX x (div n x)

sumaPotenciasDe2y3 :: [Int] -> Int
sumaPotenciasDe2y3 [] = 0
sumaPotenciasDe2y3 (x:xs)
    | esPotenciaDeX 2 x = x + sumaPotenciasDe2y3 xs
    | esPotenciaDeX 3 x = x + sumaPotenciasDe2y3 xs
    | otherwise         = sumaPotenciasDe2y3 xs
Editor is loading...
Leave a Comment