nitlanguage
/
nit.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
contrib: add `upstream.apk` to packages that have an apk
[nit.git]
/
examples
/
rosettacode
/
factorial.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: Factorial
7
# SEE: <http://rosettacode.org/wiki/Factorial>
8
9
module
factorial
10
11
redef class
Int
12
13
fun
fact
:
Int
14
do
15
if self
<
1
then return
1
16
return self
* (
self-1
).
fact
17
end
18
end
19
var
n
=
gets
.
to_i
20
print n
.
fact