Skip to content

Commit

Permalink
Update 4.iterations.md
Browse files Browse the repository at this point in the history
collatz_res
  • Loading branch information
MattBixley authored Feb 24, 2025
1 parent cd37e26 commit 82a100b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/4.iterations.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,14 @@ We constructed a loop to multiply each number by 2, but we only have 1 number as
PATH[PATH > 0]
}

# Solutions for numbers 2 to 50
# Solutions for numbers 2 to 10
collatz_res <- vector(mode = "list", length = 100 - 1)
for (numbers in 2:100) {
collatz_res[[numbers - 1]] <- collatz(numbers)
names(collatz_res)[numbers - 1] <- numbers
}

collatz_res
```

In lines 17 to 21, we applied a `while` loop to ensure that `collatz()` continues to be applied until `x == 1`, which marks the end of the loop.
Expand Down

0 comments on commit 82a100b

Please sign in to comment.