changeset 19 | 7597503194b8 |
18:e2168260b75a | 19:7597503194b8 |
---|---|
1 nil subclass: #FactorialI |
|
2 category: 't-Examples' |
|
3 ! |
|
4 |
|
5 !FactorialI class methodsFor:'examples'! |
|
6 factorialI:v <tSIntegerW> <^ tSIntegerW> |
|
7 | result <tSIntegerW> |
|
8 i <tSIntegerW> | |
|
9 |
|
10 result := 0. |
|
11 i := v. |
|
12 |
|
13 [ i > 1 ] whileTrue:[ |
|
14 result := result * i. |
|
15 i := i - 1 |
|
16 ]. |
|
17 ^ result |
|
18 ! ! |