In addition to my work stuff and fun stuff I also have dad stuff going on.

Part of that is homework stuff. Tonight my son had a list of math vocabulary words one of which was “algorithm” which needed an example.

After some googling, it was pretty obvious I was on my own.

Here’s what I came up with, maybe it’ll help some buddy…

Here is an algorithm for finding q in n ÷ m = q:

- draw m empty boxes
- count from 1 to n
- each time you count you put a dot in a box: starting from the first, then the second, etc returning to the first after you put a dot in the last box
- when you count up to n, the box with the smallest number of dots is q.
- the number of boxes with more than q dots is the remainder (r)

I gave the example of 8 ÷ 4 = q, so n = 8 and m = 4 means we need 4 empty boxes, like this:

- [ ][ ][ ][ ] start
- [. ][ ][ ][ ] count 1
- [. ][. ][ ][ ] count 2
- [. ][. ][. ][ ] count 3
- [. ][. ][. ][. ] count 4
- [..][. ][. ][. ] count 5
- [..][..][. ][. ] count 6
- [..][..][..][. ] count 7
- [..][..][..][..] count 8

And voilà, 8 ÷ 4 = 2

I’m sure there’s probably a better semi-trivial example, but this is the best I could come up with off the top of my head.

## all that remains

I realized a while back I’d forgot to take into account remainders, so I’ve added in in to the algorithm. Here is an example as well:

Let’s try out: 8 ÷ 3 = q, so n = 8 and m = 3 :

- [ ][ ][ ] start
- [. ][ ][ ] count 1
- [. ][. ][ ] count 2
- [. ][. ][. ] count 3
- [.. ][. ][. ] count 4
- [.. ][.. ][. ] count 5
- [.. ][.. ][.. ] count 6
- […][.. ][.. ] count 7
- […][…][.. ] count 8

Here we can see that the box with smallest number of dots has 2 dots, so q = 2.

Additionally, we can see that 2 boxes have 3 dots, so the remainder is 2.

Our algorithm says: 8 ÷ 3 = 2 with a remainder of 2.

Hurray!

## paul said

how did u get 7

## brianin3d said

Uhmmm… that’s actually a really good question! Changed it to say “8”…

## AyeshaAU said

I need help in computer algorithm 😦

## brianin3d said

What do you mean? You have an computer algorithm you need help with or you want a simple example of a computer algorithm or something else?