development-programming-algorithm.html


* created: 2025-06-03T16:54
* modified: 2025-06-03T17:38

title

Algorithm

description

A algorithm is a set of instruction, that, when execute, result in a desired output.

What is an algorithm?

TODO! Baking cake and kidnapping dogs.


Algorithm for adding two decimal numbers

The following steps should illustrate how we can intuitively define an algorithm for a specific task:

  1. Define the carry as 0.
  2. Define the result as 0.
  3. Start at the last digit of each number.
  4. Add the current digit of the first number, the current digit of the second number and the carry.
  5. Append the unit digit of the resulting number to the result.
  6. Store the ten's digit of the resulting number in the carry.
  7. If the end of both numbers is reached, stop; else go back to step 4.
  8. If the carry is larger than 0; append the carry to the result.
  9. Reverse the result to get the product of our addition.