JSFiddle - React, Tailwind, and code Playground

by dumptyd

JavaScript

// AAA BBB AAAAAA BBBBBB AAAAAAAAA BBBBBBBBB 

/* const f = (at, mul = 3) => {
  for (let i = 1;; ++i) {
    const v = mul * i;
    const a = v * i;
    const b = a + v;
    console.log(a, b);
    if (at <= a) return 'A';
    else if (at <= b) return 'B';
  }
};
 */
f = at => {
  for (i = 1;; ++i) {
    v = 3 * i
    if (at <= v * i) return 'A'
    else if (at <= v + (v * i)) return 'B'
  }
}


const at = 4;
console.log(`For n = ${at}: `, f(at));