Programming-Language-Benchmarks icon indicating copy to clipboard operation
Programming-Language-Benchmarks copied to clipboard

Fortran version of nsieve

Open xecej4 opened this issue 3 years ago • 1 comments

program prime
implicit none
character(30) arg1
integer i,k,M,N, kount
logical, allocatable :: flags(:)
call get_command_argument(1,arg1)
read(arg1,*)M
do k = 1,3
   N = ishft(10000,M+1-k)
   allocate(flags(N))
   flags = .true.
   do i=2, nint(sqrt(real(N)))
      if(flags(i))flags(i*2:N:i) = .false.
   end do
   kount = count(flags)
   deallocate(flags)
   print '(1x,A,1x,i10,1x,i10)','primes up to ',N,kount
end do
end program

To build and run:

gfortran -Ofast nsieve.f90 -o nsieve
time ./nsieve 10
time ./nsieve 12

xecej4 avatar Jul 13 '22 01:07 xecej4

Thanks for your contribution! However, I don't see the code in this PR. Also, to reduce the maintenance burden, I have decided to unlist less popular classic languages that are listed on CLBG, please consider making your contributions to their repo

hanabi1224 avatar Jul 14 '22 05:07 hanabi1224