Getting Started
After following the “Get Started + Install” guide;
hailstone_sequence
Compute a hailstone sequence, which defaults to the total stopping time;
hailstone_sequence(5)
#> $values
#> $values[[1]]
#> [1] 5
#>
#> $values[[2]]
#> [1] 16
#>
#> $values[[3]]
#> [1] 8
#>
#> $values[[4]]
#> [1] 4
#>
#> $values[[5]]
#> [1] 2
#>
#> $values[[6]]
#> [1] 1
#>
#>
#> $terminalCondition
#> [1] "TOTAL_STOPPING_TIME"
#>
#> $terminalStatus
#> [1] 5
Or only compute down to the regular stopping time;
hailstone_sequence(5, total_stopping_time=FALSE)
#> $values
#> $values[[1]]
#> [1] 5
#>
#> $values[[2]]
#> [1] 16
#>
#> $values[[3]]
#> [1] 8
#>
#> $values[[4]]
#> [1] 4
#>
#>
#> $terminalCondition
#> [1] "STOPPING_TIME"
#>
#> $terminalStatus
#> [1] 3
Remove verbose messaging;
hailstone_sequence(5, verbose=FALSE)
#> [[1]]
#> [1] 5
#>
#> [[2]]
#> [1] 16
#>
#> [[3]]
#> [1] 8
#>
#> [[4]]
#> [1] 4
#>
#> [[5]]
#> [1] 2
#>
#> [[6]]
#> [1] 1
It will also stop on finding a cycle;
hailstone_sequence(-56)
#> $values
#> $values[[1]]
#> [1] -56
#>
#> $values[[2]]
#> [1] -28
#>
#> $values[[3]]
#> [1] -14
#>
#> $values[[4]]
#> [1] -7
#>
#> $values[[5]]
#> [1] -20
#>
#> $values[[6]]
#> [1] -10
#>
#> $values[[7]]
#> [1] -5
#>
#> $values[[8]]
#> [1] -14
#>
#>
#> $terminalCondition
#> [1] "CYCLE_LENGTH"
#>
#> $terminalStatus
#> [1] 5
And can be parameterised;
hailstone_sequence(3, -1, 3, 1)
#> $values
#> $values[[1]]
#> [1] 3
#>
#> $values[[2]]
#> [1] -3
#>
#> $values[[3]]
#> [1] 3
#>
#>
#> $terminalCondition
#> [1] "CYCLE_LENGTH"
#>
#> $terminalStatus
#> [1] 2