C Program to find perfect numbers between 1 to 10000
write(*,*)'The perfect numbers between 1 and 10000 are:'
do i=1,10000
sum=0
do j=1,(i/2)
r=mod(i,j)
if (r.eq.0)then
sum=sum+j
end if
end do
if (sum.eq.i)then
write(*,*)i
end if
end do
end
write(*,*)'The perfect numbers between 1 and 10000 are:'
do i=1,10000
sum=0
do j=1,(i/2)
r=mod(i,j)
if (r.eq.0)then
sum=sum+j
end if
end do
if (sum.eq.i)then
write(*,*)i
end if
end do
end
Comments
Post a Comment