Write a qbasic program to display perfect number or not.

Write a qbasic program to display perfect number or not.


Ans:
CLS
INPUT "Enter a number ";n
FOR j=1 TO n-1
       IF n MOD j=0 THEN 
              Sum=Sum+j
       END IF
NEXT j
IF n=Sum THEN
       PRINT "It is perfect number"
ELSE
       PRINT "It is not perfect number"
END IF
END