Cell Division

More fun with loops…!

M. Lim
Intro to Programming
2 min readMar 5, 2018

--

→ Lab Assignment: “Cell Division” on repl.it

All of us started out as a single cell, that split in half. Then each of those 2 cells split in half, and then each of those split in half…

The total number of cells (after each cell division) is exponential — it follows the powers of 2:

We can write a program that will tell us the total number of cells in each generation, up to a certain number of generations.

To do this, we need a while loop, and TWO variables:

  • a gen variable, that represents the generation number (increases by 1 each time the loop runs)
  • a total variable, that represents the total number of cells after each generation (equal to 2 ** gen)

--

--