Untitled

Run Settings
LanguageJavaScript
Language Version
Run Command
function generateSequence(n) { let sequence = []; for (let i = 1; i <= n; i++) { let term = '1'; let currentOddNumber = 1; if (i ===2) { term += "+"; } for (let j = 3; j <= i; j++) { currentOddNumber += 2; term += '+' + currentOddNumber; } sequence.push(term); } return sequence; } console.log(generateSequence(4).join('\n')); // 1 // 1+ // 1+3 // 1+3+5
Editor Settings
Theme
Key bindings
Full width
Lines