From caeeeb2172281788e8863cafc47d2e58b16f6b94 Mon Sep 17 00:00:00 2001 From: eski Date: Sat, 16 Jan 2016 21:54:09 +0200 Subject: [PATCH 1/2] moro --- koodi.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/koodi.rb b/koodi.rb index 932f2b3..ad4d128 100644 --- a/koodi.rb +++ b/koodi.rb @@ -1 +1,13 @@ # kirjoita koodi tänne + +def kertoma(luku) + return 0 if luku == 0 + tulos = 1 + luku.times do |i| + tulos = tulos * luku + luku = luku-1 + end + return tulos +end + +kertoma(3) From 126178865fe039f366639fec88681e17032f429d Mon Sep 17 00:00:00 2001 From: eski Date: Sat, 16 Jan 2016 22:28:04 +0200 Subject: [PATCH 2/2] tulipa virhe edellisee --- koodi.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/koodi.rb b/koodi.rb index ad4d128..439c41b 100644 --- a/koodi.rb +++ b/koodi.rb @@ -9,5 +9,3 @@ def kertoma(luku) end return tulos end - -kertoma(3)