Skip to main content

All Questions

Tagged with
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 ...
user23259461's user avatar
6 votes
2 answers
202 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 ...
user avatar
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
  • 203
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 ...
xiver77's user avatar
  • 419
4 votes
1 answer
551 views

Computational verification of Collatz conjecture using OpenCL

This code review request follows my previous request Computational verification of Collatz conjecture. Unlike the previous program (which was designed for the CPU), this code should run on modern GPUs....
DaBler's user avatar
  • 309
3 votes
2 answers
152 views

Computational verification of Collatz conjecture using gmplib

Prerequisites The unsigned long type has a size of 64 bits. The following macros are defined. ...
DaBler's user avatar
  • 309
3 votes
1 answer
446 views

Computational verification of Collatz conjecture

Prerequisites The typedef name uint128_t designates an unsigned integer type with width exactly 128 bits. The ...
DaBler's user avatar
  • 309
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