You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
523 B

  1. #include "fakultaet.h"
  2. int berechneFakultaetInt(int zahl) {
  3. if (zahl == 0 || zahl == 1) {
  4. return 1;
  5. } else {
  6. int fakultaet = 1;
  7. for (int i = 2; i <= zahl; ++i) {
  8. fakultaet *= i;
  9. }
  10. return fakultaet;
  11. }
  12. }
  13. int berechneFakultaetDouble(double zahl) {
  14. if (zahl == 0 || zahl == 1) {
  15. return 1;
  16. } else {
  17. double fakultaet = 1;
  18. for (double i = 2; i <= zahl; ++i) {
  19. fakultaet *= i;
  20. }
  21. return fakultaet;
  22. }
  23. }