hailstone <- function(n) while (print(n) > 1) n <- if (n %% 2 == 0) n / 2 else 3 * n + 1;I started writing it in a very C-like way, but the functional nature of the language made itself increasingly more apparent as I played around with the code.
2014-12-16
R
Prompted by a student project, I started looking into R today.
Well, this is what the usual Hailstone program looks like in R:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment