The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 2 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Part A: The Collatz conjecture concerns what happens when we take any positive integer n and apply the following algorithm:
Â
if n is even number then n = n/2 and if n is odd number then n = 3 * n+1
Â
The conjecture states that when this algorithm is continually applied, all positive integers will eventually reach 1. For example, if n = 35, the sequence is
35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1 (35 is an odd number so 3 * 35 +1 = 106, 106 is an even number so 106 /2 = 53, so on...)
Write a C program where the user will enter the starting number. For example, if 8 is passed as a parameter on the command line, the output will be 8, 4, 2, 1. The program should accept any arbitrary integer typed in by the user. You should keep excepting user entry until the user types in a negative number (i.e. -1 or -2.) and display the output. --Â
Â
Part B: The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... The next number is found by adding up the two numbers before it. Write a program that will print the first 25 number of the Fibonacci series. -
Â