Merge: doc: fixed some typos and other misc. corrections
[nit.git] / examples / rosettacode / perfect_numbers.nit
1 #!/usr/bin/env nit
2 #
3 # This file is part of NIT ( http://www.nitlanguage.org ).
4 # This program is public domain
5
6 # Task: Perfect numbers
7 # SEE: <http://rosettacode.org/wiki/Perfect_Numbers>
8
9 module perfect_numbers
10
11
12 fun isPerfect(x: Int): Bool
13 do
14 var sum: Int = 0
15 for i in [1..(x-1)] do
16 if x%i == 0 then sum = sum+i
17 end
18 return sum == x
19 end
20
21 var n = gets.to_i
22 print isPerfect(n)