# It's raining hailstones! Download

Christina Cacioppo

if statements, while loops, logical operators
Student approved

## Introduction

The Hailstone sequence is a famous sequence that mathematicians have observed but haven't quite yet explained. Can you write a script for it?

## Task

Here's the run-down:

- Start with a whole number
`x`

.
- While
`x`

isn't 1 do the following:
a. If `x`

is even, divide it by 2.
b. If `x`

is odd, multiply it by 3 and add 1.
c. Print `x`

.
- Repeat step 2 until
`x`

is 1.

Though it appears `x`

will *always* equal 1 eventually, no one has yet figured out why.

## Starter code

```
class Hailstone{
public static void main(String [] args){
hailstones();
}
static void hailstones(){
int x = 15; // change this number if you like!
/* Your code here */
}
}
```

## Expected output

```
If you start at 15, your program should display:
15
46
23
70
35
106
53
160
80
40
20
10
5
16
8
4
2
1
```

## One solution

## Hints

## Useful tools to solve the problem

## Related links

- Amazon: Gödel Escher Bach, a book of many math puzzles, including Hailstones
- +Plus magazine: An online Hailstone evaluator
- Wikipedia: Real-life Hailstones
- Wikipedia: The Collatz Conjecture, which suggests that no matter what number starts off the Hailston sequence, it will always settle at 1.
- XKCD: Collatz' social life