Guest User

Untitled

a guest
Oct 5th, 2018
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. PROgram IS_PRIME
  2.  
  3. implicit none
  4.  
  5.  
  6. integer:: i
  7. real::sqrti
  8. integer::counter=1
  9.  
  10. read(*,*) i
  11.  
  12. if(i==2) then
  13.  print *,"prime"
  14. else if(i==1 .or. mod(i,2)==0) then
  15.  print *,"not prime2"
  16. else
  17.  sqrti=sqrt(real(i))
  18.  do
  19.   counter = counter +1
  20.   if(mod(i,counter)==0) then
  21.    print *, "not prime1",counter   
  22.    exit
  23.   end if
  24.   if(counter>sqrti) then
  25.    print *,"is prime"
  26.    exit
  27.   end if
  28.  end do
  29.  
  30.  
  31. end if
  32.  
  33. end program IS_PRIME
Add Comment
Please, Sign In to add comment