Advertisement
Guest User

Untitled

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