solutions/cw5/sqr.fun
author Christian Urban <christian.urban@kcl.ac.uk>
Fri, 05 Sep 2025 18:24:39 +0100
changeset 982 e9e5e181d9a3
parent 894 02ef5c3abc51
permissions -rw-r--r--
updated

val Max : Int = 10;

def sqr(x: Int) : Int = x * x;

def all(n: Int) : Void = {
  if n <= Max
  then { print_int(sqr(n)) ; new_line(); all(n + 1) }
  else skip()
};

{
  print_string("Squares");
  new_line();
  all(0)
}