package Pierwszy; import java.util.*; public class PotegaRekurencyjnie { public static void main(String[] args) { int b; float a, potega; Scanner skaner = new Scanner(System.in); System.out.print("Podaj podstawe potegi: "); a = skaner.nextFloat(); System.out.print("Podaj wykladnik potegi (liczba wieksza lub rowna 0: "); b = skaner.nextInt(); if (b >= 0) { potega = potegaR(a, b); System.out.println("Wynik to: " + potega); } else System.out.println("Wykladnik potegi spoza zakresu"); } public static float potegaR(float a, int b) { float c = 1; if (b == 0) c = 1; if (b > 0) c = potegaR(a, b - 1) * a; if (b < 0) c = 0; return c; } }