diff --git a/fortran/src/include/primes.f90 b/fortran/src/include/primes.f90 index 835ad51f..10bea2c5 100644 --- a/fortran/src/include/primes.f90 +++ b/fortran/src/include/primes.f90 @@ -68,17 +68,17 @@ end subroutine expand_sieve ! Function to set a bit to 0 subroutine clear_prime_bit(num) integer(i18t), intent(in) :: num - integer(i18t) :: i, b - i = (num / bits_per_int) + 1 - b = mod(num, bits_per_int) - print *, "Translating bit #", num, "to", i, b - is_prime(i) = iand(is_prime(i), ieor(-1_i18t, 2**b)) + integer :: i + i = int((num / bits_per_int) + 1) + is_prime(i) = iand(is_prime(i), ieor(-1_i18t, 2**mod(num, bits_per_int))) end subroutine clear_prime_bit ! Function to check if a bit is set logical function get_prime_bit(num) result(bit) integer(i18t), intent(in) :: num - bit = logical(btest(is_prime(num / bits_per_int + 1), mod(num, bits_per_int))) + integer :: i + i = int((num / bits_per_int) + 1) + bit = logical(btest(is_prime(i), mod(num, bits_per_int))) end function get_prime_bit end module primes diff --git a/fortran/src/p0007.f90 b/fortran/src/p0007.f90 index f6453a46..6b2d8059 100644 --- a/fortran/src/p0007.f90 +++ b/fortran/src/p0007.f90 @@ -19,6 +19,7 @@ integer(i18t) function p0007() result(answer) call expand_sieve(2_i18t**17) do i = 0, 10001 answer = next_prime(answer) + print *, i, answer end do end function p0007 end module Problem0007