# UVa 694

Jump to navigation
Jump to search

## Contents

## 694 - The Collatz Sequence[edit]

## Summary[edit]

The Collatz Sequence, also known as the 3n+1 sequence or hailstone numbers, is a sequence of numbers that will eventually enter a 4, 2, 1 loop. This problem requires you to count how many steps it takes before reaching 1, or a specified limit.

## Explanation[edit]

A "follow the instructions" problem. See also UVa 100

## Optimizations[edit]

## Gotchas[edit]

## Input[edit]

3 100 34 100 75 250 27 2147483647 101 304 101 303 -1 -1

## Output[edit]

Case 1: A = 3, limit = 100, number of terms = 8 Case 2: A = 34, limit = 100, number of terms = 14 Case 3: A = 75, limit = 250, number of terms = 3 Case 4: A = 27, limit = 2147483647, number of terms = 112 Case 5: A = 101, limit = 304, number of terms = 26 Case 6: A = 101, limit = 303, number of terms = 1