This tag should be used for code related to the sequences described in the Collatz conjecture.
5
votes
3answers
148 views
Optimize Collatz conjecture
This was the exercise:
Exercise PSD
Think about a number under 25. Write down the number. If the number is
even, divide in to two en write down the result below. If the number
isn’t even ...
3
votes
2answers
144 views
Ulam numbers (calculates your life expectancy if you want to)
I'm new to Java and wanted to present to you my latest project: Ulam Numbers
...
16
votes
1answer
90 views
Streaming Collatz
Challenge
The recent question The 3n + 1 algorithm for a range inspired me to investigate a Java-8 dependent streaming mechanism for solving the programming challenge:
For any two numbers ...
0
votes
2answers
128 views
Uva Online Judge problem 100, 3n + 1
I am having a tough time submitting this code to UVa Online judge and having it pass. I keep getting the message - Your program used more CPU time than what is allowed for this problem. That means ...
5
votes
3answers
676 views
Hailstone Sequences in Python
For the problem given:
Douglas Hofstadter’s Pulitzer-prize-winning book, Gödel, Escher, Bach, poses the following mathematical puzzle.
Pick a positive integer \$n\$ as the start.
If \$n\$ ...
1
vote
2answers
75 views
Project Euler #14 in Swift - Longest Collatz sequence
I just finished Project Euler #14 in Swift, and since there is not any version yet on Code Review, I would like to have some comments on what I did to try to improve it.
The following iterative ...
7
votes
1answer
537 views
Project Euler #14 — longest Collatz sequence
I was reading this question and realized that I didn't know Python well enough to critique the algorithm. So I wrote a Java solution instead, which is inappropriate for that question. Since there's ...
3
votes
1answer
124 views
Project Euler #14 (Longest Collatz sequence)
A Collatz sequence for a given positive integer \$n\$ is to take half of \$n\$ if even and \$3n+1\$ if \$n\$ is odd; repeat until the value goes to \$1\$. The question is which number from 1 to ...
5
votes
1answer
103 views
Hailstones and the Collatz Conjecture
The Collatz Conjecture is related to a type of problem called a Hailstone problem; because hailstones circulate up and down through a cloud around a planet until they eventually fall. The Collatz ...
8
votes
1answer
198 views
Horridly Inefficient Project Euler #14 in Python - Collatz Sequences
I created this solution a while ago, and have been going back over my problems to try to make them all more efficient. I have been stuck on this one, and have tried a few different ideas. So far, my ...
-3
votes
1answer
2k views
hailstone sequence using recursion in python
Douglas Hofstadter's Pulitzer-prize-winning book, Gödel, Escher, Bach, poses the following mathematical puzzle:
Pick a positive integer n as the start.
If n is even, divide it by 2.
If n is ...