troyatistic

Untitled

Sep 17th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class PotenssienSumma {
  5.  
  6.     public static void main(String[] args) {
  7.         Scanner lukija = new Scanner(System.in);
  8.  
  9.         System.out.print("Anna luku: ");
  10.         int potenssi = Integer.parseInt(lukija.nextLine());
  11.  
  12.         int luku = 2;
  13.         double tulos = 0;
  14.  
  15.         while (potenssi >= 0) {
  16.             tulos = (Math.pow(luku, potenssi)) + (Math.pow(luku, potenssi+1));
  17.             potenssi++;
  18.            
  19.             System.out.print(tulos);
  20.             System.out.print(potenssi);
  21.             System.out.print(luku);
  22.         }
  23.  
  24.         tulos = (int) Math.pow(luku, potenssi);
  25.         System.out.print("Tulos on: " + tulos);
  26.  
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment