Skip to content

Metternich11/algorithm-night-collatz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Collatz Sequence

Instructions

Create a function which computes the Collatz Conjecture sequence for a positive integer n. The sequence is calculated as follows:

  • If n is even, the next number in the sequence is n / 2
  • If n is odd, the next number in the sequence is 3 * n + 1
  • If n is 1, we have reached the end of the sequence (notice that once we reach 1, the sequence will end up in a loop of 1 => 4 => 2 => 1)

Now, create a second function which finds the number n with the longest Collatz sequence between 1 and positive integer i. If two numbers have the same sequence length, return the smaller of the two numbers.

  1. Fork this respository
  2. Clone it
  3. Solve it
  4. Submit pull request

Read More

To read more about the Collatz Conjecture, see the links below: https://en.wikipedia.org/wiki/Collatz_conjecture https://www.youtube.com/watch?v=5mFpVDpKX70&feature=share

About

Toy problem for CodeWorks algorithm night.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published