Digital FXtbook
Easy Contacts
  • Home
    • Free Software
    • The Author
    • Former Students Hall of Fame
    • A tribute....
  • Animation
    • Intro to 3d >
      • AutoDesk
      • Introduction: The Temple
      • Troubleshooting Maya
      • Modeling >
        • The Nail
        • First Freestyle Lesson >
          • Cup and Straw
          • Garbage Can
        • Fence
        • Hammer
        • House
        • Environment Bubble
      • Animation >
        • Beginning Animation
        • Animation - Walk Cycle
        • Facial Animation
      • Rendering >
        • Arnold Rendering
      • StoryBoarding
      • Story Reels
      • Editing film >
        • Video Editing
        • Credits
      • Characters
      • Troubleshooting
    • Modeling and Rigging >
      • Modeling >
        • Image Planes
        • Polygon Modeling >
          • Coke Can
          • Low Polygon Character
          • Character Modeling Legion the Geth
          • Character Modeling Geth Armor
          • Face Modeling
        • NURBS Modeling >
          • Intro to NURBS
          • Lofting
          • CV Curves
          • Organic Modeling
          • Autombile
      • 3d Coat >
        • Integration with Maya >
          • Getting stuff out of Maya
        • UV Texture Mapping >
          • Texture mapping in 3d Coat
        • 3d Painting >
          • Painting in 3d Coat
        • Reintegration with Maya
      • Rigging >
        • Rigging
        • Smooth Skinning
        • Rigging with HumanIK
        • Smooth Skinning
      • Motion Capture
    • 3d Animation >
      • Arnold Rendering
      • Reference Videos
      • Beginning Animation
  • Gaming
    • Board Game Game Design Document
    • Modeling >
      • Introduction: The Temple
      • Halo 1 Blood Gulch Base
      • Hammer
      • Sword
      • Character Modeling Big Daddy
      • Shield
      • The OM6G
      • Weapon
      • Character Modeling Legion the Geth
      • Character Modeling Geth Armor
    • Animation >
      • Character Animation
    • Rigging >
      • Rigging with HumanIK
      • Characterizing and MoCap
      • Integration with Unity
    • Unity >
      • Number Wizard Game #1
      • Second Unity Game: Text Adventure
      • Number Wizard Game GUI
      • Block Breaker >
        • Block Breaker Game #1
        • Block Breaker Game #2
        • Block Breaker Game #3
        • Block Breaker Game #4
      • Terrain
      • Importing Models
  • Coding
    • Beginning C# >
      • First Unit >
        • First Program
        • Introduction Unity Lesson
        • Comments
        • PsuedoCode
        • Numbers and Operators
        • Use of Parenthesis
        • Casting
        • Try and Catch
        • Operators
      • Second Unit >
        • Conditional Statements >
          • Number validator
          • Number tester
          • Speed Camera
        • Random Class
        • Loops >
          • For Loops
          • For Each Loops
          • While Loops
          • Do While Loops
        • Arrays >
          • Simple Arrays
          • Complex Arrays
    • Web Design >
      • XHTML >
        • XHTML Introduction
        • XHTML Test #1
        • HTML Links and Images
        • XHTML Test #2
        • HTML Tables and Lists
        • XHTML Test #3
        • HTML intro to CSS
        • HTML CSS
        • HTML Styling
        • HTML Styles
        • HTML Positioning
      • HTML 5 >
        • HTML Chapter 1
        • HTML Chapter 2
        • HTML Chapter 3
        • HTML Chapter 4
        • HTML Chapter 5
        • HTML Chapter 6
        • HTML Chapter 7
        • HTML Chapter 8
        • HTML Chapter 9
  • Student Films
    • Advanced Student's movies
    • Beginning Student's movies
  • Adobe
    • Photoshop >
      • Introduction
      • Selection Tools >
        • Melonhead >
          • Melonhead Creative
        • Breakfast Lunch or Dinner
        • Blu 42
      • Painting Tools >
        • Invisi-World
        • Image Adjustment
        • FreeStyle project
      • Drawing Tools >
        • Abstract Expressionism
    • Premier >
      • Project 1
    • Illustrator >
      • Vector Ninjas
      • Live Art Painting
      • Starting the Pen Tool
      • Apple and Pear
      • Creating Your LOGO
      • Self Portrait
  • Links
    • Key Board Fix/Hack
    • Buiding Piers >
      • Buiding Piers
      • Buiding Piers
    • The Top Six Animation Schools
    • The Top Video Game Design Schools
  • International Team
  • BPA
    • BPA 2017-2018 >
      • Getting organized
      • Building the Train
      • Texturing the Train
      • Animating the Train
      • Making our Entry Film
    • BPA 2018-2019
    • BPA 2019-2020
  • Arnold Lighting
  • Example for 1st Hour

Collatz's Hypothesis

​In 1937, a mathematician named Lothar Collatz formulated an intriguing hypothesis that remains unsolved to this day (perhaps this would be a good challenge for you?) which can be described in the following way:

1. take any non-negative and non-zero integer number and name it c0;
2. if it's even, evaluate a new c0 as c0 / 2
3. otherwise, if it's odd, evaluate a new c0 as 3 ⋅ c0 + 1
4. if c0 ≠ 1, skip to point 2

The hypothesis says that, regardless of the initial value of c0, it will always (always!) go to 1.

Of course, it's an extremely complex task to use a computer in order to prove the hypothesis for any natural number (it may in fact need artificial intelligence), but you can use C++ to check some individual numbers.

Maybe you can find the one that disproves the hypothesis and become a famous mathematician.

Okay, let's start. Write a program which reads one natural number and executes the above steps as long as c0 remains different from 1.

Moreover, we'll give you another task – we want you to count the steps needed to achieve the goal. Your code should output all intermediate values of c0, too – it'll be very illustrative, won't it?

Hint: the most important part of the problem is how to transform Collatz's idea into a "while" loop – this is the key to success. Test your code using the data we've provided

​

Video


Testing data

Example input
15

Example output
46
23
70
35
106
53
160
80
40
20
10
5
16
8
4
2
1

steps = 17

Example input
16 

Example output
8
4
2
1

steps = 4

Example input
1023

Example output
3070
1535
4606
2303
6910
3455
10366
5183
15550
7775
23326
11663
34990
17495
52486
26243
78730
39365
118096
59048
29524
14762
7381
22144
11072
5536
2768
1384
692
346
173
520
260
130
65
196
98
49
148
74
37
112
56
28
14
7
22
11
34
17
52
26
13
40
20
10
5
16
8
4
2
1

​steps = 62 
Proudly powered by Weebly