Skip to content

Instantly share code, notes, and snippets.

@hekyou
Created March 26, 2012 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hekyou/2203313 to your computer and use it in GitHub Desktop.
Save hekyou/2203313 to your computer and use it in GitHub Desktop.
変数を新たに宣言せずに1から100までの整数の和を表示するプログラムを作れ
-- ./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