From 691947f2d5a510420459f4cfa745891440cea346 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 14 May 2009 20:19:53 -0500 Subject: solution to problem 20 --- 020.bc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 020.bc (limited to '020.bc') diff --git a/020.bc b/020.bc new file mode 100644 index 0000000..d538cfe --- /dev/null +++ b/020.bc @@ -0,0 +1,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 -- cgit v1.2.3