Find the 6th term of the series 14, 28, 20, 40,….. Using JavaScript.
Anonymous:
64
Answers
Answered by
3
- import java.io.*;
- class GFG {
- static int findNth(int N)
- {
- int b = 14;
- int i;
- for (i = 2; i <= N; i++) {
- if (i % 2 == 0)
- b = b * 2;
- else
- b = b - 8;
- }
- return b;
- }
- public static void main (String[] args) {
- int N = 6;
- System.out.print(findNth(N));
- }
- }
Similar questions