From 0f615df05a27d015b79e9c3873b159561cd7b2be Mon Sep 17 00:00:00 2001 From: Olivia Appleton Date: Tue, 1 Oct 2024 02:34:20 -0500 Subject: [PATCH] Attempt p76 in fortran (7) --- fortran/src/include/primes.f90 | 4 +--- fortran/src/include/ranges.f90 | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/fortran/src/include/primes.f90 b/fortran/src/include/primes.f90 index 7648b2be..42afe91a 100644 --- a/fortran/src/include/primes.f90 +++ b/fortran/src/include/primes.f90 @@ -56,9 +56,7 @@ subroutine expand_sieve(potential_n) deallocate(prime_sieve) end if allocate(prime_sieve(new_size)) - do i = 1, new_size - prime_sieve(i) = -1 - end do + prime_sieve = -1 call clear_prime_bit(0_i18t) call clear_prime_bit(1_i18t) call sieve_up_to(new_n) diff --git a/fortran/src/include/ranges.f90 b/fortran/src/include/ranges.f90 index 3c41ad8e..93977970 100644 --- a/fortran/src/include/ranges.f90 +++ b/fortran/src/include/ranges.f90 @@ -18,6 +18,9 @@ integer function range_entry4(start, stop, step, idx) result(answer) length = 1 + (stop - 1 - start) / step elseif (step < 0 .and. start > stop) then length = 1 + (start - 1 - stop) / (-step) + else + answer = huge(kind(answer)) ! error + return end if if (l_idx < 0) then