Advertisement
joelhenrique

Untitled

Feb 25th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.34 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Azi{
  4.     public static void main(String[] args) {
  5.        
  6.         int numeroInput = 4;
  7.         int umOuDois = 1;
  8.         double resultado = 0;
  9.        
  10.         for(int i = 1; i<=numeroInput; i++){
  11.             umOuDois = i % 2 == 0 ? 2 : 1;
  12.             resultado += (Math.pow(numeroInput + umOuDois, 2) / i);
  13.         }
  14.  
  15.         System.out.println(resultado);
  16.  
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement