Skip to content

Commit

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

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

0 comments on commit 4b00524

Please sign in to comment.