0
How to display the first ten series: 1,--3,5,-7,9,.............
The first term of the series must be positive and then negative and then positive and then so on.
3 Respostas
+ 5
Like this?
for (int i = 1, count = 0; count < 10; i+=2) {
System.out.print((count % 2 == 0 ? "" : "-") + i + " ");
count++;
}
+ 3
(-1)**(n%2)*(2*n+1)
0
Hint: The nth element of the series is equal to a_{n-1}+4*n*(-1)^n