Hello,
programmieren hat immer was mit strukturiertem Denken zu tun - kann ich nicht gut, arbeite trotzdem seit Jahren in der Branche, gibt also auch andere Qualitäten. Aber nichts desto trotz sollte man sich mal klar machen, wie denn eine Fakultät eigentlich definiert ist, d.h. was man machen muss, um sie zu errechnen.
Nun gut, Schule, also wird wohl irgendwann Rekursion dran sein, das find ich für die Fakultät eigentlich dankbarer, weil es näher an der Berechnungsvorschrift ist, aber egal.
Fakultät iterativ berechnen heißt beispielsweise:
- nimm dir die Zahl und merke sie dir als Zwischenergebnis
- reduziere die Zahl um eins
- multipliziere die neue Zahl mit dem Zwischenergebnis
- reduziere die Zahl um eins
- multipliziere....
- ...so lange, bis die Zahl = 1 ist.
Erkennst du das Schleifenmuster?
MfG
Rouven
--
-------------------
He is entertaining both out of the car and in the car because if you tell him that a corner is almost flat then he is the guy who is going to try to take it flat even if it means shunting it the other side of it, he will come with the data and say 'hey, I may have crashed and destroyed the car, but I was flat-out'. That is an interesting quality that he has! -- Team Member on Jacques Villeneuve
-------------------
He is entertaining both out of the car and in the car because if you tell him that a corner is almost flat then he is the guy who is going to try to take it flat even if it means shunting it the other side of it, he will come with the data and say 'hey, I may have crashed and destroyed the car, but I was flat-out'. That is an interesting quality that he has! -- Team Member on Jacques Villeneuve