You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

29 lines
548 B

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