packages feed

funcons-simple-0.1.0.3: tests/Kdiverse/Kdiverse2.smp

// copied from K: tests/diverse/factorial.simple
// The following program calculates the factorial of a user-provided number.

function factorial(y) {
  print("Factorial of ", y, " is: ");
  var t=1;
  for(var i=1; i<=y; ++i) {
    t = t*i;
  }
  return t;
}

function main() {
  print("Input a natural number: ");
  print(factorial(read()),"\n");
}