Skip to content

ex1 03

← Back

Basic Info

Functional Programming
└── Lab ML
    └── 0​314
        └── ex1 03.sml

Preview

(*
Write a program to compute the square of an integer, using the formula

n^2 = (n − 1)^2 + 2n − 1
*)

fun square(0) = 0
    | square(n) = square(n-1)+2*n-1;