Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PROgram IS_PRIME
- implicit none
- integer:: i
- real::sqrti
- integer::counter=1
- read(*,*) i
- if(i==2) then
- print *,"prime"
- else if(i==1 .or. mod(i,2)==0) then
- print *,"not prime2"
- else
- sqrti=sqrt(real(i))
- do
- counter = counter +1
- if(mod(i,counter)==0) then
- print *, "not prime1",counter
- exit
- end if
- if(counter>sqrti) then
- print *,"is prime"
- exit
- end if
- end do
- end if
- end program IS_PRIME
Add Comment
Please, Sign In to add comment