C Program to find prime or composite number
write(*,*)'Input the integer:'
read(*,*)n
kount=0
if (n.gt.1)then
do i=1,(n/2)
l=mod(n,i)
if (l.eq.0) then
kount=kount+1
end if
end do
if (kount.eq.1)then
write(*,*)'The number is prime.'
else
write(*,*)'The number is composite.'
end if
else
write(*,*)'Wrong input, give a right input.'
end if
end
write(*,*)'Input the integer:'
read(*,*)n
kount=0
if (n.gt.1)then
do i=1,(n/2)
l=mod(n,i)
if (l.eq.0) then
kount=kount+1
end if
end do
if (kount.eq.1)then
write(*,*)'The number is prime.'
else
write(*,*)'The number is composite.'
end if
else
write(*,*)'Wrong input, give a right input.'
end if
end
Comments
Post a Comment