Computer Science, asked by ZinuAngel, 4 months ago

Write two separate java programs to print the following series

a.

0,1,1,2,3,5,8, 13……...n terms. n is taken as input

b.

1,4,9,16,………..n terms n is taken as input​

Answers

Answered by umeshnirmal04
2

Answer:

Nth Term = (N % 2 == 0) ? (N - 1) : (N + 1)

1st term = (1 % 2 == 0) ? (1 - 1) : (1 + 1)

= (1 + 1)

= 2

2nd term = (2 % 2 == 0) ? (2 - 1) : (2 + 1)

= (2 - 1)

= 1

3rd term = (3 % 2 == 0) ? (3 - 1) : (3 + 1)

= (3 + 1)

= 4

4th term = (4 % 2 == 0) ? (4 - 1) : (4 + 1)

= (4 - 1)

= 3

Therefore, Series = 2, 1, 4, 3

Answered by AkashSharma752027107
2

find by using Sn formula

ok

Similar questions