Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Long Sequence
- Write a program that prints the first 1000 members of the sequence: 2, -3, 4, -5, 6, -7, …
- You might need to learn how to use loops in Java (search in Internet).
- Input
- There is no input for this task.
- Output
- Output the first 1000 members of the sequence, each on a separate line.
- 2
- -3
- 4
- -5
- 6
- ...
- */
- for (let num = 2; num <= 1002; num++) {
- if (num % 2 === 0) {
- console.log(num);
- } else {
- console.log(num - (num * 2));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement