'OxygenBasic

uses console

function perf(int n) as int
  int sum,i
  string ls
  for i = 2 to <n
    if mod(n,i) = 0
      sum += i
    end if
  next
  if sum = n-1 'PERFECT NUMBER
    ls=n ":" tab "1"
    for i = 2 to <n
      if mod(n,i) = 0
        ls+=" "+i
      end if
    next
    printl ls
    return n
  end if
end function

int n
for n = 2 to 10000
  perf(n)
next

printl "done"
waitkey
