## Archive for the ‘**Puzzles**’ Category

## More thoughts on the Collatz Conjecture

I made a quick housekeeping sweep of the blog recently, and wanted to revisit the Collatz Conjecture. I’m sure it’s been suggested before, but I believe there’s another method of proving the conjecture:

for all where

That is to say, we only need prove that for an n > 2, all integers between consecutive powers of 2 resolve according to the collatz conjecture. I’m not sure where to go from there, but for instance we can show that in general:

where r is the number of (divisible by 3) iterations such that

## Takkuso’s Cycles

I saw an interesting post on /r/math today, and decided to write a small script to play around with it.

- Pick a positive integer, i
- Find the magnitude, m, of the difference between i and i’s reverse, j
- Repeat step 2 using m; you will eventually hit either 0 or a special number.

The special number is 21, followed by min(0, log10(i)-4) 9s, then 78.

A quick table:

# of digits | Special number |

4 | 2178 |

5 | 21978 |

6 | 219978 |

7 | 2199978 |

Below is the Python script in full, followed by a quick example usage. I’m hoping to do some graphs when I get home.

## Digit counting in Python

Question: what’s the fastest way to count the number of digits (base 10) in an integer (integral type, could be long) in python?

This came up when I was working on a ProjectEuler problem. There are three options I came up with, and we can rule the first out immediately:

- Divide (as an integer) the number by ten and keep a counter of how many times we divided it, until the number is 0.
- Use log(n, 10) and properly account for floating point black magic
- Convert to a string, get the length

## Experimenting with the Collatz Conjecture and C#’s GC

# For those new to the Collatz Conjecture

## EDIT: Commented the latex tabular code. Get it here.

More after the break. Read the rest of this entry »