Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fatc :: Integer -> Integer
- fatc n | n==0 = 1
- | n>0 = fatcauda n 1
- fatcauda :: Integer -> Integer -> Integer
- fatcauda n parcial | n==0 = parcial
- | n>0 = fatcauda (n-1) (n*parcial)
- size :: [Int] -> Int
- size [] = 0
- size (head: body) = 1 + size body
- divi :: Int -> [Int]
- divi n = [x | x<-[1..n], mod n x == 0]
- divip :: Int -> [Int]
- divip n = [x | x<-[2..n-1], mod n x == 0]
- primo :: Int -> Bool
- primo n | [x | x<-[2..n-1], mod n x == 0] == [] = True
- | otherwise = False
- primos :: Int -> [Int]
- primos n | n> 2 = [x | x<-[1..n], primo x]
- multi :: Int -> Int -> [Int]
- multi n i = [x*n | x<-[1..i]]
- --pi :: Int -> Double
- --pi n = (426880 * sqrt 10005) / divpi n
- divpi :: Integer -> Double
- divpi k = (((fatc (6*k)) * ((545140134*k) + 13591409))/((fatc (3*k)) * (pot (fatc k) 3) * (pot (-262537412640768000) k)))
- pot :: Integer -> Integer -> Integer
- pot base expo | expo == 0 = 1
- | otherwise = base * (pot base (expo-1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement