Tangential comments about Software Development

Sunday, October 30, 2011

Algol for Interviewing

Next time I'm interviewing a programmer for a job, I'd like to use this fragment of Algol. It comes from Electronic Computers by Hollingdale and Tootill (published 1965) which I stole from my brother-in-law's bookshelves.

begin comment Evaluate pi from Vieta's formula;
  real e, f, product; integer count;
  e := read tape;
  f := 0; product := 1; count := 0;
  for count := count + 1 while f < 2 - e do
    begin f:= sqrt( 2 + f );
      product := product x f/2
  newline; print (2/product); print (count)

Good algorithm, better maths. Sixteenth century Italy was an advanced place intellectually.