diff options
author | Jack Sangdahl <[email protected]> | 2024-12-17 13:18:18 -0700 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2024-12-17 13:18:18 -0700 |
commit | be030b74805f245c8618c77b03e76f16b3fc945a (patch) | |
tree | 9054d2c2b8ded0a404613a25c5b158cfbe02dc50 /introductory_problems/readme.md | |
download | cses-be030b74805f245c8618c77b03e76f16b3fc945a.tar.gz cses-be030b74805f245c8618c77b03e76f16b3fc945a.zip |
1608. weird algorithm
Diffstat (limited to 'introductory_problems/readme.md')
-rw-r--r-- | introductory_problems/readme.md | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/introductory_problems/readme.md b/introductory_problems/readme.md new file mode 100644 index 0000000..1ff88eb --- /dev/null +++ b/introductory_problems/readme.md @@ -0,0 +1,8 @@ +## Introductory Problems + +### Weird Algorithm +Consider an algorithm that takes as input a positive integer `n`. If `n` is even, the algorithm divides it by two, and if `n` is odd, the algorithm multiplies it by three and adds one. The algorithm repeats this, until `n` is one. Your task is to simulate the execution of the algorithm for a given value of `n`. + +**Input**: The only input line contains an integer `n`. (Example: 3) + +**Output**: Print a line that contains all values of `n` during the algorithm. (Example: 3 10 5 16 8 4 2 1) |