Advertisement
Spocoman

11. Sum of Odd Numbers

Jan 12th, 2022
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function sumOfOddNumbers(n) {
  2.     sum = 0;
  3.     for (let i = 1; i < n * 2; i += 2) {
  4.         sum += i;
  5.         console.log(i);
  6.     }
  7.     console.log(`Sum: ${sum}`)
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement