Advertisement
Guest User

Untitled

a guest
Sep 16th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 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.  
  14.         while (potenssi >= 0) {
  15.             double tulos = (Math.pow(luku, potenssi)) + (math.pow(luku, potenssi++));
  16.         }
  17.  
  18.         int tulos = (int) Math.pow(luku, potenssi);
  19.         System.out.print("Tulos on: " + tulos);
  20.  
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement