Skip to content

Commit

Permalink
Solve p14 in fortran (4)
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Oct 9, 2024
1 parent 4b00524 commit 5a69815
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fortran/src/p0014.f90
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ end function p0014

recursive subroutine collatz_len(answer, n, collatz_len_cache)
integer(i18t), intent(in) :: n
integer, intent(out) :: answer = 0
integer, intent(out) :: answer
integer, intent(inout), dimension(:) :: collatz_len_cache
if (n < collatz_cache_size .and. collatz_len_cache(int(n)) /= 0) then
answer = collatz_len_cache(int(n))
return
end if
answer = 0
if (mod(n, 2) == 1) then
call collatz_len(answer, (3 * n + 1) / 2, collatz_len_cache)
answer = answer + 2
Expand Down

0 comments on commit 5a69815

Please sign in to comment.