From 5a6981565975f2c879fc3a1693fab5e3f0652137 Mon Sep 17 00:00:00 2001 From: Olivia Appleton Date: Tue, 8 Oct 2024 01:14:19 -0500 Subject: [PATCH] Solve p14 in fortran (4) --- fortran/src/p0014.f90 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fortran/src/p0014.f90 b/fortran/src/p0014.f90 index 03108ef2..e8391282 100644 --- a/fortran/src/p0014.f90 +++ b/fortran/src/p0014.f90 @@ -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