Computer Science, asked by Anonymous, 11 months ago

Find the 6th term of the series 14, 28, 20, 40,….. Using JavaScript.


Anonymous: 64

Answers

Answered by AbhijithPrakash
3
  1. import java.io.*;  
  2. class GFG {  
  3.  
  4. static int findNth(int N)  
  5. {  
  6. int b = 14;  
  7. int i;  
  8. for (i = 2; i <= N; i++) {  
  9.  if (i % 2 == 0)  
  10.   b = b * 2;  
  11.  else
  12.   b = b - 8;  
  13. }  
  14. return b;  
  15. }  
  16. public static void main (String[] args) {  
  17.  int N = 6;  
  18. System.out.print(findNth(N));  
  19. }  
  20. }

Anonymous: Thanks a Lot!!
AbhijithPrakash: Welcome :)
Similar questions