correctly label euler solutions
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user