summaryrefslogtreecommitdiff
path: root/test/files/script/fact.scala
blob: a15c93452ca48b52f98572173be15a04db3bacda (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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))