CS 116
Nov. 4, 2002
Try this:
Loop1.java
from the web page. Try it
out. Be sure you try entering both positive and negative values for the
loop termination.
for
loop rather than a while
loop.
x
. If x
is even, the function returns x/2
. If
x
is odd, the function returns 3x+1
. If we iteratively apply
this function to numbers larger than 1, mathematicians believe the sequence
of values eventually returns to 1. Write a little program (you can use
Loop1.java
as a starting point) in which the user enters a starting
number and then we loop and print out the values as long as x
is not
equal to 1.
Array1.java
from the web page. Try it
out. Be sure to try search for values that are in the array and values
that are not.
Print the frequencies after they are all computed to the console.