// Arithmetic through the `Num` trait (dictionary passing) and plain
// recursion.
import std/io
fn sum_to :: n: a i: a step: a acc: a -> a where Num, Ord
{
if i > n
{
acc
}
else
{
sum_to n (i + step) step (acc + i)
}
}
fn fib :: n: Int -> Int
{
if n < 2
{
n
}
else
{
fib (n - 1) + fib (n - 2)
}
}
pub fn main :: -> () /
{
io.println (show (sum_to 3000000 0 1 0) <> " " <> show (fib 30))
}
//> 4500001500000 832040