summaryrefslogtreecommitdiff
path: root/euler92.myr
blob: 30924052b602458636cd7ec6c0ac4beb8473d5f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use std

const goto89 = {x
	const sqrsum = {y
		var sum = 0
		while y > 0
			var b = y % 10
			y = y / 10
			sum += b * b
		;;
		-> sum
	}
	while x != 1 && x != 89
		x = sqrsum(x)
	;;
	-> x == 89
}

const main = {
	var n = 0
	for var i = 1; i < 10_000_000; i++
		if goto89(i)
			n++
		;;
	;;
	std.put("{}\n", n)
}