correctly label euler solutions

This commit is contained in:
2025-12-23 17:08:42 +01:00
parent e447d4d7cd
commit 3be891c7cc
17 changed files with 139 additions and 131 deletions

View File

@@ -1,22 +1,13 @@
func collatz_num[n: i64] : i64
if n % 2 == 0
return n / 2
return n * 3 + 1
func collatz_seq[n: i64]: i64
let i: i64 = 1
while n != 1
n = collatz_num(n)
i = i + 1
return i
func main[] : i64
let max: i64 = 0
let max_index: i64 = 0
let out: i64 = 0
for i in 1..1000000
let seq: i64 = collatz_seq(i)
if seq > max
max = seq
max_index = i
io.println_i64(max_index)
for a in 500..1000
for b in 500..1000
if a * b > out
let s: str = str.from_i64(a * b)
let s_rev: str = str.reverse(s)
if str.equal(s, s_rev)
out = a * b
mem.free(s)
mem.free(s_rev)
io.println_i64(out)