diff options
Diffstat (limited to 'test/files/script/fact.scala')
-rwxr-xr-x | test/files/script/fact.scala | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/files/script/fact.scala b/test/files/script/fact.scala new file mode 100755 index 0000000000..a15c93452c --- /dev/null +++ b/test/files/script/fact.scala @@ -0,0 +1,15 @@ +#!/bin/sh +# fact - A simple Scala script that prints out the factorial of +# the argument specified on the command line. + +exec scalascript "$0" "$@" +!# + + +val x = Integer.parseInt(argv(0)) + +def fact(x: Int):Int = + if(x==0) 1 + else x*fact(x-1) + +Console.println("fact(" + x + ") = " + fact(x)) |