C has three looping keywords: do, for, and while. These keywords construct a block of statements that repeat, hopefully but not necessarily with a terminating condition. Other programming languages offer additional looping keywords, including the popular and useful foreach.
Continue reading
Harmonic Series, Divergence, and C Code
A harmonic series is a mathematical contraption that deals with cascading fractions. Like the Fibonacci series, I thought I could easily code a harmonic series in C — which I did, but not before reading up on the topic of divergence.
Continue reading
Fun With Series: Fibonacci and Harmonic
My maths grades were horrible. I understand the concepts, but failed at solutions in class because I’d make silly mistakes. Computers make mistakes only when they’re programmed to do so, which means maths are far more enjoyable for me as a coder. For example, take the Fibonacci sequence.
Continue reading
Some Weighty Conversions – Solution
This month’s Exercise is to create a program that converts weight measurements by using this format:
nnnFT
Where nnn is a value, F is the unit to convert from, and T is the unit to convert to. This problem is more of an input-parsing exercise than a straight conversion.
Continue reading
My Chicken McNuggets Solution

The Chicken McNuggets problem, presented in last week’s Lesson, shows code that outputs the highest McNuggets number from 1 to 100. This value isn’t a combination of 6, 9, or 20, the number of the pieces offered in the McDonald’s Chicken McNuggets packages.
Continue reading
Some Weighty Conversions
The three units of weight I’m familiar with are pounds, kilograms, and stone. For me, stone is the odd one. I’ve heard it used in Britain and it’s completely baffling to me, often requiring that I whip out a calculator to see what “14 stone” really means. Better, I could write code that converts between pounds, kilograms, and stone, which is the goal of this month’s Exercise.
Continue reading
The Chicken McNuggets Problem

Chicken McNuggets come several to a box, depending on what you order: six pieces for a kid, nine pieces for an adult, or twenty pieces for an honest adult. These numbers in various combinations form what the math nerds call McNugget Numbers.
Continue reading
The Golden Ratio – Recursion Version
Oh, how I distrusted recursion when I was a budding programmer. It’s just a tough concept to wrap your head around, especially if you’re an old warhorse Assembly programmer like me who lives in fear of blowing up the stack. Trivial asides aside, recursion often presents an elegant and efficient way to solve a programming puzzle.
Continue reading
The Golden Ratio
Like many other mathematical delights, the golden ratio pops up all over. It has a rich history, and a special Greek letter to represent it: φ phi. The value is irrational, meaning it cannot be expressed as a ratio of two integers: 1.6180339…
Continue reading
Calculating Months – Solution
The task for this month’s Exercise is to return the month number for a time_t value. Effectively you extract the year and month, do some math, presto. Could it be this easy?
Continue reading