30 lines
548 B
Fortran
30 lines
548 B
Fortran
c Fortran version of a Prime Number Finder
|
|
c haplo@mindstab.net
|
|
|
|
program primes
|
|
implicit none
|
|
real test, i;
|
|
integer isPrime, amax, cnt;
|
|
character *32 buff;
|
|
if (iargc() >= 1) then
|
|
call getarg(1, buff);
|
|
read(buff, *) amax;
|
|
else
|
|
print*, "Useage: primesf [Max Num]";
|
|
return
|
|
endif
|
|
|
|
do cnt = 3, amax, + 2
|
|
test = sqrt(float(cnt));
|
|
isPrime=1;
|
|
do test = 3, test, +2
|
|
if (mod(cnt, int(test)) == 0) then
|
|
isPrime=0;
|
|
exit;
|
|
endif
|
|
enddo
|
|
if(isPrime /= 0) print*,cnt
|
|
c if(isPrime /= 0) write(*,'(I3.1)'),cnt
|
|
enddo
|
|
end
|