Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- System.out.print("Digite o valor do termo: ");
- int value = scanner.nextInt();
- double answer = 0;
- for(int i = 2; i <= value; i++){
- double topValue = i;
- double bottomValue = (i-1) * (i-1);
- if(i % 2 == 0){
- answer = answer + (topValue / bottomValue);
- } else{
- answer = answer - (topValue / bottomValue);
- }
- }
- System.out.println("O valor do termo é " + answer);
- scanner.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement