Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(n) {
- let counter = Number(n);
- let sum = 0;
- let odd = 1;
- for (let i = 1; i <= counter; i++) {
- sum += odd;
- console.log(odd);
- odd += 2
- }
- console.log(`Sum: ${sum}`)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement