ocaml: phase 5.1 harshad.ml baseline (count Niven/Harshad numbers <= 100 = 33)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
A Harshad (or Niven) number is divisible by its digit sum:
let count_harshad limit =
let c = ref 0 in
for n = 1 to limit do
if n mod (digit_sum n) = 0 then c := !c + 1
done;
!c
count_harshad 100 = 33
All single-digit numbers (1..9) qualify trivially. Plus 10, 12, 18,
20, 21, 24, 27, 30, 36, 40, 42, 45, 48, 50, 54, 60, 63, 70, 72, 80,
81, 84, 90, 100 (24 more) = 33 total under 100.
133 baseline programs total.
This commit is contained in:
@@ -59,6 +59,7 @@
|
||||
"grid_paths.ml": 210,
|
||||
"group_consec.ml": 53,
|
||||
"hailstone.ml": 111,
|
||||
"harshad.ml": 33,
|
||||
"hamming.ml": 4,
|
||||
"hanoi.ml": 1023,
|
||||
"hist.ml": 75,
|
||||
|
||||
Reference in New Issue
Block a user