# Copyright (C) 2008, The Perl Foundation.
# $Id: /mirror/trunk/languages/squaak/examples/factorial.sq 28321 2008-06-13T09:23:59.825553Z kjs  $

print("Please enter number: ")
x = read()

sub factorial(n)
    ## test for < 2 because all numbers are represented by
    ## floating-point numbers, and equality checks on those
    ## do not work (yet?)
    if n < 2 then
        return 1
    else
        return n * factorial(n - 1)
    end
end

print("factorial of ", x, " is: ", factorial(x))


