Newer
Older
zweic / tests / 1 / t1.zwei
@glproj03 glproj03 on 20 Nov 2005 266 bytes *** empty log message ***
class Factorial {
// Solution itérative
def factorial1 (x : Int ): Int = {
var p : Int = 1;
while (x > 0 ) {
set p = p * x;
set x = x - 1;
}
p
};
// Solution récursive
def factorial2 (x : Int ): Int =
if (x == 0 ) 1
else x * this.factorial2 (x - 1 );
}