Programming Challenges:110507 The Stern-Brocot Number System

Last night I was bored, and decided to tackle a Programming Challenges problem: 110507 The Stern-Brocot Number System seemed easy, and in the end it was.

However it took two attempts, due to messing up the termination logic. ie run till m and n are both 1

I first had:

    while (m != 1 && n != 1)

instead of:

    while (m != 1 || n != 1)

maybe I should have used

    while (!(m == 1 && n == 1))

Gosh I dislike double negatives to loop logic.

This entry was posted in Programming and tagged . Bookmark the permalink.

One Response to Programming Challenges:110507 The Stern-Brocot Number System

  1. Pingback: Programming Challenges Problems - Easist to Hardest

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use a subset of HTML tags and attributes