Skip to main content

All Questions

Filter by
Sorted by
Tagged with
3 votes
2 answers
552 views

Contest Solution: Hailstones

The Problem In the January 1984 issue of Scientific American, an interesting sequence of numbers known as a hailstone series was described. The series is formed by generating the next number ...
T145's user avatar
  • 3,137
1 vote
3 answers
665 views

Euler Project 14 Longest Collatz Sequence [closed]

I have been working through the euler project and I have created the following code for Problem 14, which asks which starting number, under 1 million, produces the longest Collatz Sequence chain. It ...
johnashu's user avatar
  • 423
4 votes
2 answers
8k views

Project Euler #14 - Longest Collatz Sequence in Python

I recently solved Project Euler Problem 14 in Python: The following iterative sequence is defined for the set of positive integers: ...
D Farmer's user avatar
12 votes
2 answers
2k views

"Longest Collatz sequence" in C slower than in Python 3

This tight-looped memoization-less C solution to Project Euler's problem 14 seems efficient, but ran much slower than a similarly trivial Python 3 program. For the desired ...
user133296's user avatar
5 votes
2 answers
197 views

Euler Project 14 (Longest Collatz Sequence)

Project Euler 14 asks: Which starting number, under one million, produces the longest Collatz sequence? I've been trying to optimize this solution to execute in less then 1s. Agenda for first 50 ...
Simon's user avatar
  • 1,012
3 votes
2 answers
617 views

Efficient solution to Project Euler 14 (Longest Collatz sequence)

This is an iterative review. I asked for reviews on a Collatz sequence generator here. I tried to address all of the suggestions that were made. I've added a new function ...
Vermillion's user avatar
10 votes
4 answers
3k views

3n + 1 programming challenge in Python

I am trying to find a efficient solution for the 3n + 1 problem on uvaonlinejudge. The code I have uses memoization using a dictionary. I am getting a 'Time limit Exceeded' error when I submit the ...
Omar Khan's user avatar
  • 201
2 votes
3 answers
2k views

Determine Collatz sequence length for given starting values

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 ...
Teererai Marange's user avatar
4 votes
1 answer
2k 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 ...
Husnain Raza's user avatar
3 votes
1 answer
826 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,...
Inphynite's user avatar
9 votes
1 answer
620 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 ...
Jose Magana's user avatar
-2 votes
1 answer
9k views

hailstone sequence using recursion in python [closed]

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 ...
overexchange's user avatar
  • 3,351