Created
March 26, 2012 06:01
-
-
Save hekyou/2203313 to your computer and use it in GitHub Desktop.
変数を新たに宣言せずに1から100までの整数の和を表示するプログラムを作れ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- ./test 100 | |
module Main where | |
import System | |
main = do | |
max <- getArgs | |
print (test (read (head max)::Integer)) | |
test :: Integer -> Integer | |
test 1 = 1 | |
test n = n + test (n - 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment