Write a program to find the Perfect numbers between 1 to 10000 .
Program Coding
Program Perfect_numbers
Implicit none
Integer :: i , x , Sum
write (*,*) "List of Perfect Numbers:"
Do x = 2 , 10000
Sum = 0
Do i = 1,x/2
If ( mod (x,i) == 0) then
Sum = Sum + i
end if
end do
If(x /= Sum) Cycle
If(x == Sum) then
write (*,*) x
End if
end do
stop
end program
!Output
No comments:
Post a Comment