module VerificadorCuitCuil where

verificarCuil :: Int -> Bool
verificarCuil = verificarCuit

verificarCuit :: Int -> Bool
verificarCuit n
    | n <= 20000000000 || n > 99999999999 = False
    | otherwise = digVerif == if calcVerif == 11 then 0 else calcVerif
    where
        digVerif = n `mod` 10
        x = listaDigitos $ n `div` 10
        y = sum $ zipWith (*) x l
        calcVerif = 11 - y `mod` 11
        l = [5,4,3,2,7,6,5,4,3,2]

listaDigitos :: Int -> [Int]
listaDigitos n
    | n == 0 = []
    | otherwise = listaDigitos (n `div` 10) ++ [n `mod` 10]
