|
News
Lab Schedule
QuickBasic Notes
Fortran Notes
Tutor Room
Winplot Manual
Lab Home
xxxxxxxxxxxxxxxxxx
| |
program checkprime
integer n
character result*9
c This program determines whether an integer is prime.
print *, "Please enter a positive integer :"
read *, n
call check(n,result)
print *
print *, "The integer", n, " is ", result, ". Bye."
end
subroutine check(n,result)
integer n, i, root
character result*9
if (n .eq. 1) then
result = "not prime"
return
end if
root = sqrt(real(n))
do i = 2, root
if (mod(n,i) .eq. 0) then
result = "not prime"
return
end if
end do
result = "prime"
end
|