|
-
Feb 14th, 2009, 09:04 PM
#1
Thread Starter
Hyperactive Member
Collatz Conjecture / Collatz Tree
I have made a WPF application that constructs a Collatz Tree for the collatz conjecture problem. The collatz conjecture is that any number will eventually reach and terminate at 1 by following these steps:
If the number is even, divide the number by 2.
If the number is odd, multiply the number by 3 and add 1.
Repeat until number has reached 1.
Here is an example starting with 3:
3
10 (3x3+1)
5 (10/2)
16 (5x3+1)
8 (16/2)
4 (8/2)
2 (4/2)
1 (2/1)
The sequence starting with any number eventually reaches a 2^n number which is where it then begins to terminate.
My program (optionally) starts with 1 and shows the paths to reach 1.
Here is a screenshot:

The red numbers are numbers that satisfy the following: (n - 1) mod 3 = 2. All numbers under a red number will not branch out both directions; each of the red nodes can only have 1 child.
Last edited by Arrow_Raider; Feb 14th, 2009 at 09:22 PM.
My monkey wearing the fedora points and laughs at you.
-
Feb 14th, 2009, 09:50 PM
#2
Re: Collatz Conjecture / Collatz Tree
Neat. Never heard of that stuff but a none-the-less
-
Feb 15th, 2009, 04:26 AM
#3
Re: Collatz Conjecture / Collatz Tree
Nice. I've heard of Collatz before but it's obviously not as interesting as Happy Numbers. However, now that you've made a graph, you have upped the appeal of Collatz, giving Happy Numbers some real competition. Well done.
-
Feb 15th, 2009, 07:11 AM
#4
Re: Collatz Conjecture / Collatz Tree
The graph is upside down and I don't like the colour.
-
Feb 15th, 2009, 07:57 AM
#5
Re: Collatz Conjecture / Collatz Tree
7 was coming after 11 - wasn't it...
It all makes sense now.
-
Feb 15th, 2009, 08:02 AM
#6
Re: Collatz Conjecture / Collatz Tree
9 and 14 as well - that's a curious spot - can you show the tree below that branch?
-
Feb 15th, 2009, 10:14 AM
#7
Thread Starter
Hyperactive Member
Re: Collatz Conjecture / Collatz Tree
I'll be releasing the source code soon, but I need to clean it up first.
Here is the tree under node 11:

This is the code I am using to generate the tree:
Code:
private BinaryTreeOfLong GenerateTree(int node, int n)
{
if (n > 0)
{
BinaryTreeOfLong t = new BinaryTreeOfLong();
t.Value = node;
if ((node - 1) % 3 == 0)
{
if (((node - 1) / 3) % 2 == 1 && (node - 1) / 3 != 1)
{
t.LeftSubtree = GenerateTree((node - 1) / 3, n - 1);
}
}
else if ((node - 1) % 3 == 2)
t.Flag1 = true;
t.RightSubtree = GenerateTree(node * 2, n - 1);
return t;
}
else
return null;
}
Note: BinaryTreeOfLong is basically BinaryTree<long>. I don't know how to get xaml to work with generics, so I just did it like that. I'll figure out how to use generics in xaml eventually... but I was too lazy yesterday.
Last edited by Arrow_Raider; Feb 15th, 2009 at 10:20 AM.
My monkey wearing the fedora points and laughs at you.
-
Feb 15th, 2009, 10:33 AM
#8
Re: Collatz Conjecture / Collatz Tree
The "master numbers" behind 11 are remarkable...
But that's a different discussion.
-
Feb 15th, 2009, 10:37 AM
#9
Thread Starter
Hyperactive Member
Re: Collatz Conjecture / Collatz Tree
Do master numbers rule over mendhak's happy numbers?
My monkey wearing the fedora points and laughs at you.
-
Feb 15th, 2009, 12:49 PM
#10
Re: Collatz Conjecture / Collatz Tree
-
Apr 6th, 2010, 07:32 AM
#11
New Member
Re: Collatz Conjecture / Collatz Tree
Hi Arrow:
Can you post the entire code for the Collatz Tree?
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|