This commit is contained in:
David Doblas Jiménez 2022-10-12 20:19:06 +02:00
parent 948dfb0ff8
commit 3cf341159b
2 changed files with 6 additions and 5 deletions

View File

@ -15,6 +15,7 @@ function Problem13()
#=
Work out the first ten digits of the sum of the following one-hundred
50-digit numbers =#
return string(sum(parse.(BigInt, readlines("../files/Problem13.txt"))))[1:10]
end

View File

@ -9,7 +9,7 @@ https://projecteuler.net/problem=14 =#
using BenchmarkTools
function chain_length(n)# , terms)
function chain_length(n)
length = 0
while n > 1
n = iseven(n) ? n >> 1 : 3n + 1
@ -42,7 +42,7 @@ function Problem14()
ans = 0
limit = 1_000_000
score = 0
for i in 1:2:limit # no need to check even numbers
for i = 1:2:limit # no need to check even numbers
longest = chain_length(i)
if longest > score
score = longest