Skip to main content

Posts

Showing posts from July, 2022

Friday Quiz maths question 8 Jul 22

  H o w  many three-digit numbers are ther e where the middle digit is lower than  both the first digit and the third digit ? My reaction to this is to loop through all of the numbers 100-999 and count the ones that pass the test. (yes, lines 40 and 45 look a little inelegant with that repetition, but I tried it with a goto (yuk) and gosub and this was the shortest and neatest of my variations.  I wanted to print the qualifying numbers as well as inc'ing the count). I remember a very similar question in the past, involving 3-digit numbers. I think it was Mr Beckett who used a single loop in Forth and wrote words to separate out the hundreds, tens and units.  (Seemed a little counter-intuitive to me but Forth doesn't allow you access to the indices of three nested loops). So I thought I'd give that a go to see whether it would be more elegant than the BASIC version.  Here are my 'hundreds', 'tens' and 'units' words (made easier as the default type in ...