working while, non-working do/while

This commit is contained in:
Dmitry Jemerov
2011-04-01 18:44:10 +02:00
parent d4d9ac7b8e
commit 230c6efe99
5 changed files with 64 additions and 19 deletions
+9
View File
@@ -0,0 +1,9 @@
fun fac(i: Int): Int {
var count = 1;
var result = 1;
do {
count = count + 1;
result = result * count;
} while(count != i);
return result;
}
+9
View File
@@ -0,0 +1,9 @@
fun fac(i: Int): Int {
var count = 1;
var result = 1;
while(count < i) {
count = count + 1;
result = result * count;
}
return result;
}