sumaPotenciasDe2y3.hs

mail@pastecode.io avatar
unknown
haskell
19 days ago
424 B
3
Indexable
Never
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
Leave a Comment