This tag should be used for code related to the sequences described in the Collatz conjecture.

learn more… | top users | synonyms

8
votes
1answer
88 views

I CAN HAS EULR 14, PLZ?

A few days ago I found myself learning lolcode. It turns out it's (almost) a real language and capable of handling (pseudo-)serious problems. So, let's try some (pseudo-)serious code this time. ...
2
votes
3answers
59 views

Calculating the Collatz Conjecture

Today I read this thing about the Collatz Conjecture and wanted to try and write a program that calculates all the numbers. If you have any idea how the code could be shortened, please tell me. ...
3
votes
4answers
84 views

Find out the number under 1 million which produces the largest Collatz Sequence

So, I have written a code which calculates the number under n( 1 million in this case) which produces the largest Collatz Sequence in that ...
1
vote
3answers
110 views

3n+1 problem rejected by uva judge: time limit exceeded

I am trying to get into the habit of solving programming puzzles in my spare time but am stuck on the first one(which I know can be for a large number of reasons hence my posting for help). Shown ...
4
votes
1answer
583 views

Memoized Collatz sequence

Here is one of my programs that utilized memoization and array to improve performance and memory usage. The performance seems satisfactory but the memory usage is ridiculous and I can't figure out ...
2
votes
0answers
80 views

Project Euler #14 in Clojure (finding long Collatz sequence chain)

I'm working on a Clojure implementation for Project Euler #14, which asks for the initial element, under 106, that produces the longest collatz-sequence chain. I'm trying to make use of every ...
-1
votes
1answer
112 views

Code that calculates Hailstone Sequence of input numbers, and code that calculates the number with the largest Hailstone sequence smaller than `z`

I managed to make a simple function that calculates the Hailstone sequence of numbers and print it out, and I just done a calculator that grabs the number with the largest sequence smaller than ...
4
votes
1answer
150 views

Collatz Sequence in Python

I'm trying to use Python to solve the Project Euler problem regarding the Collatz sequence. With some research online, I have come up with the code below. However, it still takes a long time to find ...
6
votes
2answers
78 views

Calculating numbers in the Collatz sequence

I have found two ways in which I can generate the Collatz sequence given a start number. I have looked briefly into their performance, but I'd like a more in depth/solid review into the difference in ...
5
votes
3answers
285 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
194 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 ...
17
votes
1answer
134 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
319 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 ...
6
votes
3answers
3k 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\$ ...
2
votes
2answers
107 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 ...
9
votes
1answer
2k 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
203 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 1,000,...
5
votes
1answer
121 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 ...
9
votes
1answer
274 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 ...
-2
votes
1answer
3k 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 ...