Skip to content

Commit

Permalink
Attempt p7 in fortran (20)
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Oct 3, 2024
1 parent 63166fb commit 4b51376
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions fortran/src/include/primes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ subroutine expand_sieve(potential_n)
do i = 1, new_size
is_prime(i) = 2**bits_per_int - 1
end do
call clear_prime_bit(0)
call clear_prime_bit(1)
call clear_prime_bit(0_i18t)
call clear_prime_bit(1_i18t)
call sieve_up_to(new_n)
current_n = new_n
end subroutine expand_sieve
Expand All @@ -72,7 +72,7 @@ subroutine clear_prime_bit(num)
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, 2**b))
is_prime(i) = iand(is_prime(i), ieor(-1_i18t, 2**b))
end subroutine clear_prime_bit

! Function to check if a bit is set
Expand Down
3 changes: 2 additions & 1 deletion fortran/src/p0007.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
! What is the 10 001st prime number?

module Problem0007
use constants
use primes
implicit none
contains
integer function p0007() result(answer)
integer(i18t) function p0007() result(answer)
integer :: i

answer = 1
Expand Down

0 comments on commit 4b51376

Please sign in to comment.