NichtHaskell/Examples/Fakultaet.java
2024-07-04 11:04:33 +02:00

21 lines
434 B
Java

class Fakultaet {
public int fak(int number) {
if (number < 0) {
return 1;
}
int factorial = 1;
int i = 1;
while(i <= number){
factorial = factorial * i;
i = i + 1;
}
return factorial;
}
public static void main(String[] args) {
Fakultaet f = new Fakultaet();
int result = f.fak(5);
print(result);
}
}