subroutine get_prime(isPrime, N) implicit none integer::i,j,N integer,parameter::prime=1,nonprime=0 integer,allocatable::isPrime(:) isPrime=prime isPrime(1)=nonprime do i=2, FLOOR(SQRT(REAL(N))) if(isPrime(i).eq.prime) then do j=i+i, N, i isPrime(j) = nonprime end do end if end do end subroutine get_prime program main interface subroutine get_prime(isPrime, N) integer::N integer,allocatable::isPrime(:) end subroutine get_prime end interface integer::primelimit integer*8::total integer,allocatable::isPrime(:) read *, N,L primelimit = L/(N-1) if(primelimit.lt.2) then print '(i0)', 0 return end if allocate(isPrime(primelimit)) call get_prime(isPrime, primelimit) total = 0 do i=1, primelimit if(isPrime(i).eq.0) cycle total = total + (L-(N-1)*i) + 1 end do print '(i0)', total end program