sumaPotenciasDe2y3.hs

 avatar
unknown
haskell
10 months ago
424 B
6
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