[back]

Path Records

We consider one last variation of the collatz function. The path value of a number \(n\) is the largest number that appears during the collatz procedure starting at \(n\). For example, the path value of 5 is 16.1 We say that \(n\) has a path record if its path value is greater than that of any previous number.

Implement the function

val path_record : int -> int

so that path_record n is the \(n\)th path record. Note that this is not the \(n\)th value with a path record; it's the path value of the \(n\)th value with a path record.

Examples

let _ = assert (path_record 0 = 1)
let _ = assert (path_record 1 = 2)
let _ = assert (path_record 2 = 16)
let _ = assert (path_record 3 = 52)

Footnotes:

1

See the example on the collatz page.