Download 4. Hailstone Sequence (Wondrous Numbers)

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Positional notation wikipedia , lookup

Non-standard calculus wikipedia , lookup

Location arithmetic wikipedia , lookup

Arithmetic wikipedia , lookup

Series (mathematics) wikipedia , lookup

Large numbers wikipedia , lookup

Law of large numbers wikipedia , lookup

Approximations of π wikipedia , lookup

Expected value wikipedia , lookup

Elementary mathematics wikipedia , lookup

Collatz conjecture wikipedia , lookup

Transcript
FIU-DEPARTMENTOFELECTRICALANDCOMPUTERENGINEERING
4. Hailstone Sequence
(Wondrous Numbers)
EEL 4746L - Microcomputers-I Lab
EEL 4746L
Lab Manual 4
FIU Dept. of Elect. And Comp. Eng.
Aim: Computing and displaying the Hailstone sequence numbers.
Background:
A mathematical conjecture, still unproven, first proposed by Dr. Lothar Collatz in 1937 states that the
function
will always converge with the sequence “…, 8, 4, 2, 1” for any initial value of n. Before the
sequence converges to unity, the value of the function can be incrementing or decrementing.
Implementation:
1. Ask user to input the initial value (seed value)  first value of ‘n’. This should be a
positive integer greater than 0 and of up to three digits (1 - 999).
2. Compute f(n).
3. Display the value. Note that the value can be single, double, triple or quadruple digit.
Hence you will have to perform 16-bit operations. Since ‘n’ is always a positive (nonnegative) integer, the maximum number that can be obtained in the computations will be
65535.
Extra points (5): When a number is displayed, display only the non-­‐zero digits.
4. Take this value and the value of ‘n’ for the next iteration and continue till you obtain ‘1’ as
answer. Notice that for any initial value of ‘n’, the sequence always ends with “…., 8, 4, 2, 1”.
5. After the iterations are completed, display the number of iterations that the function took to
“converge”.
6. Implement the program for 10 different seed values, note the iteration steps required and the
converging sequence and describe your observations in the conclusion.
Test:
You can use MS Excel program to test the implementation. If the seed value is in A1 cell,
implement the following formula in A2 cell and extend the formula to the cell below.
=IF(A1=1,"DONE",IF(MOD(A1,2)=0,A1/2,A1*3+1))
References:
1. http://boinc.thesonntags.com/collatz/
2. Lab handouts