(* Harshad numbers are integers that are divisible by the sum of their digits. For example, 42 / (4 + 2) = 7, so 42 is a Harshad number. However, 76 / (7 + 6) is not an integer, so 76 is not. ("Harshad" is Sanskrit for "joy giver".) Numberphile: 2016502858579884466176 (16:48) https://www.youtube.com/watch?v=dgwevhEykWQ "There doesn't seem to be anything directly practical you can do with Harshad numbers, but you can use them to exercise your mathematical muscles" -- and practice writing code in Klein. *) function main(n: integer): boolean divides(sum_of_digits(n), n) function sum_of_digits(n: integer): integer if n < 10 then n else MOD(n, 10) + sum_of_digits(n/10) (* recurring utility, from sieve.kln *) function divides(a: integer, b: integer): boolean MOD(b, a) = 0 (* utility function from lib.kln *) function MOD(m: integer, n: integer ): integer m - m/n * n