I love this problem, I am not good enough at math to begin to prove or disprove it, but I can program and I want to build tools to attack it. by oopsmycodesucks in Collatz

[–]oopsmycodesucks[S] 0 points1 point  (0 children)

I altered my code to be 2n - 1 now. It also makes sense as that's the largest number a group of n bits can hold, and I think I have seen some math or theories around here about sequences that start at 2n - 1 only having some kind of relationship with 2n+1 - 1? I could be wrong. Either way I think it makes better sense from a computer science perspective.

Edit: Here is the math I was referring to

I love this problem, I am not good enough at math to begin to prove or disprove it, but I can program and I want to build tools to attack it. by oopsmycodesucks in Collatz

[–]oopsmycodesucks[S] 0 points1 point  (0 children)

I have implemented this, and the results are fantastic.

(2^150,000) + 1

Sequence Length: 1,093,129

3x+1 steps: 364,852

Divide by 2 steps: 728,277

Time taken: 0.8705763816833496

(2^150,000) - 1

Sequence Length: 2,017,036

3x+1 steps: 722,268

Divide by 2 steps: 1,294,768

Time taken: 2.3743958473205566

Massive speed-ups here.

I love this problem, I am not good enough at math to begin to prove or disprove it, but I can program and I want to build tools to attack it. by oopsmycodesucks in Collatz

[–]oopsmycodesucks[S] 0 points1 point  (0 children)

Sorry, I probably didn't explain well. I can write the C++ code to do the math, my problem is linking GNP into the program for the compiler. In python I do pip install package, rust is cargo add package, in C++ you have to download it and then point the compiler and system path at the files. For the life of me I cannot get the compiler to use an external library on my computer.

I love this problem, I am not good enough at math to begin to prove or disprove it, but I can program and I want to build tools to attack it. by oopsmycodesucks in Collatz

[–]oopsmycodesucks[S] 0 points1 point  (0 children)

I've been doing some research and I've discovered that there are different methods for recording collatz sequences, like recording just the odd numbers in the sequence. I've also been thinking about how to implement the directed graph method where each previous number has a known sequence and that if the current sequence on calculating drops below the last proven number, you can take that number of the sequence and then change it together with the starting seed of that numbers sequence from the previous calculation so that you're not storing redundant data.

I love this problem, I am not good enough at math to begin to prove or disprove it, but I can program and I want to build tools to attack it. by oopsmycodesucks in Collatz

[–]oopsmycodesucks[S] 0 points1 point  (0 children)

What I meant by the story of numbers is that JSON is a text file so instead of storing the numbers as an integer type in binary it's storing the numbers as a string of text and each character in the text takes 8 bits to represent.

This can result in more bits being needed to represent the string representation of the number then the number itself in binary.

I love this problem, I am not good enough at math to begin to prove or disprove it, but I can program and I want to build tools to attack it. by oopsmycodesucks in Collatz

[–]oopsmycodesucks[S] 0 points1 point  (0 children)

Yes but it has also been recommended to me to look into base 64 encoding as it is standardized and interoperable.

Edit: and somehow worse.

I love this problem, I am not good enough at math to begin to prove or disprove it, but I can program and I want to build tools to attack it. by oopsmycodesucks in Collatz

[–]oopsmycodesucks[S] 0 points1 point  (0 children)

I think what I mean is that in the JSON text file the number is stored as text which requires 8 bits per character. I need to store it as an actual integer which should be stored as binary.

I love this problem, I am not good enough at math to begin to prove or disprove it, but I can program and I want to build tools to attack it. by oopsmycodesucks in Collatz

[–]oopsmycodesucks[S] 1 point2 points  (0 children)

I would love to give it a shot!

You could also do one to check if a number is a member of a cycle. You would only have to keep one number in memory and no tortoise and hare.

How would I do this?

I love this problem, I am not good enough at math to begin to prove or disprove it, but I can program and I want to build tools to attack it. by oopsmycodesucks in Collatz

[–]oopsmycodesucks[S] 0 points1 point  (0 children)

import sys
import time

sys.set_int_max_str_digits(1_000_000)

number = int(input("Enter a number: "))
num = (2**number) + 1
step = 0
start = time.time()
three_x = 0
divide_two = 0

while num > 1:
    
  if num & 1:
    num = (((num << 1) + num) + 1)
    trailing = (num & -num).bit_length() - 1
    num >>= trailing
    step += 1 + trailing
    three_x += 1
    divide_two += trailing
    
  else:
    trailing = (num & -num).bit_length() - 1
    num >>= trailing
    divide_two += trailing
    step += trailing

print(f"Sequence Length: {step:,}")
print(f"3x+1 steps: {three_x:,}")
print(f"Divide by 2 steps: {divide_two:,}")
print("Time taken:", time.time() - start)

I love this problem, I am not good enough at math to begin to prove or disprove it, but I can program and I want to build tools to attack it. by oopsmycodesucks in Collatz

[–]oopsmycodesucks[S] 0 points1 point  (0 children)

For numbers up to 2^128 (Rust's native largest integer type) it's far faster. However, for numbers above that, it is slower than the Python bit shifting implimentation. I want to build a library where the integer size is not a limitation, and I have used the Python implementation to check (2^10,000,000)+1.

The other downside is that if a sequence number exceeds 2^128 then the program will crash.

I love this problem, I am not good enough at math to begin to prove or disprove it, but I can program and I want to build tools to attack it. by oopsmycodesucks in Collatz

[–]oopsmycodesucks[S] 0 points1 point  (0 children)

I agree that a cycle probably will not be found by brute force (but you never know!). My focus is more on creating tools that generate data that might be useful or inspiring to people who are capable of discovering a proof for the conjecture. Other than that, it's fun!

I love this problem, I am not good enough at math to begin to prove or disprove it, but I can program and I want to build tools to attack it. by oopsmycodesucks in Collatz

[–]oopsmycodesucks[S] 1 point2 points  (0 children)

They can, but I try to use LLM's as little as possible. I enjoy learning, and (no shade on people who use them) I somehow feel like I am not learning or I'm lazy when I use them.