Function that takes a positive integer N and returns the sum of the bits in the binary representation. For example bits(7) is 3 and bits(8) is 1. Direct and tail-recurive versions.
Calculates perimeter, area and enclosing rectangle for different types shape:
{ circle, { X, Y }, R }: circle (centre, radius){ rectangle, { X, Y }, W, H }rectangle (centre, width, height)