Added Fakultaet.java as a Example for friday
This commit is contained in:
parent
e801717444
commit
4dfea0d69d
20
src/Fakultaet.java
Normal file
20
src/Fakultaet.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user