Advertisement
polpoteu

JAVA x^n pętle FOR

Oct 25th, 2018
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. package e9.pkgfor;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class E9For {
  6.  
  7. public static void main(String[] args) {
  8.  
  9. int licznik=1, potega=1, x,n;
  10. Scanner sc = new Scanner(System.in);
  11. System.out.println("Wprowadź X");
  12. x = sc.nextInt();
  13. System.out.println("Wprowadź N");
  14. n = sc.nextInt();
  15. for (int i = 0; i <= n; i++) {
  16. potega *=x;
  17. licznik +=1;
  18. System.out.println(potega);
  19. }
  20. }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement