C Program to check whether a number is perfect or not
write(*,*)'Input the number:'
read(*,*)n
sum=0
write(*,*)'The factors excluding that number are:'
do i=1,(n/2)
r=mod(n,i)
if (r.eq.0)then
write(*,*)i
sum=sum+i
end if
end do
if (sum .eq. n)then
write(*,*)'The number is perfect.'
else
write(*,*)'The number is not perfect.'
end if
end
write(*,*)'Input the number:'
read(*,*)n
sum=0
write(*,*)'The factors excluding that number are:'
do i=1,(n/2)
r=mod(n,i)
if (r.eq.0)then
write(*,*)i
sum=sum+i
end if
end do
if (sum .eq. n)then
write(*,*)'The number is perfect.'
else
write(*,*)'The number is not perfect.'
end if
end
Comments
Post a Comment