Farewell 2021 with 3n+1

  • Email
  • Sharebar
  • Email
Andy's picture

The Youtube algorithm one day pushed a video "The Simplest Math Problem No One Can Solve - Collatz Conjecture" to me. After viewing the video, I thought that my VRMath2 could easily visualise the 3n+1 graph with its LOGO programing. I am happy that my VRMath2 application is still working after almost three years in low maintenance mode. With some simple coding. I have written a LOGO program that can take a number (natural number) and the turtle will draw its 3n+1 graph. The 3n+1 problem is simple. It starts with a natural number; if the number is odd, multiply it by 3 then add one; if the number is even, the number is divided by 2. These rules apply until the resulting number is one. It is interesting that it seems any given natural number will end with 1 after applying the 3n+1 rules, but how?

Below is the graph for the number 2021 (the date when this blog is wriiten is 31-12-2021), so to farewell 2021.

The LOGO codes are explained below:

The logic or the 3n+1 rules are coded from line 19 to 27.  Within this WHILE loop, the SETXYZ will move the turtle to the coordinate, which has the n as the Y coordinate, the step as the X coordinate, and alway 0 as the Z coordinate. I have also recorded a short video below showing how you could try it for yourself. 

The 3n + 1 conjecture predicts that no matter which positive integer is given, the number sequence will eventually reach 1. In trying the 3n + 1 program in VRMath2 Editor, I have also developed some questions for further investigation:

  • Would the bigger number have longer sequence?
  • Would every number have different number of step? 
  • Can you find 3 numbers that will have the same number of steps in their sequences?
  • What number will keep being even when divided by 2, all the way to 1?
  • What is special about 3n+1? Why not 2n+1 or 4n+1 or 3n+3?
  • What other ways can the number sequence be visualised?

Please leave a comment to let me know what you think.

Files3n_plus_1.x3d | 3n_plus_1.logo

Facebook Comments Box