Skip to main content
Code Review

Questions tagged [collatz-sequence]

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

Filter by
Sorted by
Tagged with
9 votes
4 answers
2k views

"Weird Algorithm" (Collatz) from CSES Problem Set

I had to solve the following problem: 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 ...
6 votes
2 answers
200 views

Collatz - another view

Most coders have, at one time or another, dabbled with "The Collatz Conjecture"; a pair of simple math operations that seem to always find their way cycling through ...
3 votes
1 answer
135 views

Collatz conjecture plots (python)

I have tried to improve my code with the suggestions I recieved in my old question about Collatz conjecture Here is the new code: ...
4 votes
3 answers
712 views

Plotting Collatz conjecture values - Python

I am writing a program to display the behavior or certain seeds when you apply the Collatz conjecture algorithm to them. I would like to know what I should change and also if there is a way to see ...
10 votes
2 answers
2k views

Collatz sequence in C

First of all, if you're unfamiliar with the Collatz sequence, it recursively applies the following function to an integer: $$ f(n) = \begin{cases} n/2 & \text{if } n \equiv 0 \pmod{2}, \\ 3n+1 &...
nyz's user avatar
nyz
  • 203
3 votes
3 answers
1k views

Automate the boring stuff with Python - The Collatz Sequence

The Collatz Sequence Write a function named collatz() that has one parameter named number. If ...
2 votes
1 answer
101 views

Meta Collatz Sequence

Context Chapter 6 of Learn You A Haskell contains a function called chain, which outputs the Collatz sequence of a given input. (In short, it takes a natural number....
7 votes
1 answer
235 views

A Python 3 script that generates art using matplotlib

I am always super interested in both science and art, science and art are two different ways to describe the objective reality, they are two sides of the same coin, in many areas they overlap, and ...
3 votes
2 answers
187 views

Beating the compiler with a simple program finding the longest collatz sequence

I found this question in Stackoverflow asking why his/her assembly program isn't faster than the C++ program. In his/her assembly program I saw the lines ...
3 votes
1 answer
244 views

Collatz conjecture with plots

I have an assignment where I write a Collatz Conjecture program for a series of starting values from 1 to N and make two plots: number of iterations vs starting value and computed numbers vs starting ...
2 votes
0 answers
223 views

Maximizing Efficiency of Collatz Conjecture Program Python

My question is very simple. I wrote this program for pure entertainment. It takes a numerical input and finds the length of every Collatz Sequence up to and including that number. I want to make it ...
2 votes
1 answer
937 views

How to make my Collatz Conjecture code run a lot faster? (and even better, how do I implement it into multiple computers?) Python

I have been writing this piece of code for a while now, and I was wondering, is it possible to run this code multiple times on my pc? For example could I make the code solve all the numbers from 1 to ...
5 votes
2 answers
241 views

Project Euler Problem #277

I am trying to solve Euler project problem 277 using python 3.8. First, I will show my program and than ask specific questions for enhancements. The problem is a modified version of Collatz sequence. ...
6 votes
2 answers
680 views

Basic Collatz program with input validation in Python

In chapter 3 of Automate the Boring Stuff with Python by Al Sweigart, one exercise asks to write a program which performs the Collatz sequence. I wrote a basic version first, then added and ...

15 30 50 per page
1
2 3 4 5 6

AltStyle によって変換されたページ (->オリジナル) /