Hailstone sequence: infinite loop

Tell us what’s happening:

hello, I would like someone to help me, in this and other challenges I have had the same problem: the compiler says that I have an infinite loop corresponding to the while loop, I consider that it is not true, if someone has had this problem or knows how to solve it, please appreciate the answer

Your code so far

// noprotect
function hailstoneSequence() {
const res = [];
// Good luck!
var i=0, seq, sLen, max=0, n;
// noprotect
  seq = hailstone(i);
  sLen = seq.length;
  if (sLen > max) {
      n = i;
      max = sLen;
function hailstone (n) {
  var seq = [n];
  while (n > 1) {
      n = n % 2 ? 3 * n + 1 : n / 2;
  return seq;
return res;

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36.

Challenge: Hailstone sequence

Link to the challenge:

Hi and welcome to the forum!

You are triggering the infinite loop protection in the interpreter because your loop takes a very long time to run. This is a sign that you need to make your approach more efficient.