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 ); }