Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
INIT-REF committed Jul 9, 2024
1 parent 258d0c2 commit b84f43e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions 021.fut
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
def divsum(n: i32) = if n == 1 then 1 else
reduce (+) 0 (map(\x -> if n % x == 0 then x else 0) (1...(n / 2)))
def divsum(n: i32) = if n == 1 then 1
else (1...(n / 2)) |> map (\x -> if n % x == 0 then x else 0) |> i32.sum

def amicable(n: i32) = if divsum(n) != n && divsum(divsum(n)) == n then n else 0

def main = reduce (+) 0 (map(\x -> amicable(x)) (1...10000))
def euler021(limit: i32) = (1...limit) |> map amicable |> i32.sum

def main = euler021 10000

0 comments on commit b84f43e

Please sign in to comment.