summaryrefslogblamecommitdiffstats
path: root/020.bc
blob: 67d113cd080fc82a6ead5508dae32e810b19c418 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
















                           
    
#!/usr/bin/bc

scale = 0

# from the bc man page
define fact (x) {
    if (x <= 1) return (1);
    return (fact(x-1) * x);
}

total = 0
num = fact(100)
while (num > 0) {
    total += num % 10
    num = num / 10
}
total
halt