#!/usr/pkg/bin/wsbasic


#function without parameters
function hello()
begin
  print "hello there!"
end

#function with parameters
function test(a,b,c)
begin
  print "a=", a, ", b=", b, ", c=", c
  print "a+b+c= ", a+b+c
  print ""
end


#function that returns something
function square(i)
begin
  return i*i
end


function fac(i)
begin
  if(i<=1) begin
    return 1
  end
  else begin
    return i*fac(i-1)
  end
end

#
#this is the main block
#for ease no begin-end is needed here! 
#
glob=5
hello()
test(1,2,3)

print "k=";
k=fac(5)
print k 
 
j=1
while j<10 begin
  print "fac(",j,")=",fac(j)
  j=j+1
end
  
print ""
print "-glob        =" , -glob
print "square(-glob)=" , square(-glob) 


