josiftepe

Untitled

Nov 8th, 2020
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. // korisnikot vnesuva eden broj n, treba da napiseme funkcija koja ke ni go vraka faktorielot od toj broj
  5. int faktoriel(int broj) {
  6.     //5! = 5 * 4 * 3 * 2 * 1 = 120
  7.     //6! = 120 * 6
  8.     //7! 720 * 7 = 5040
  9.     int fakt = 1;
  10.     for(int i = 1; i <= broj; i++) {
  11.         fakt *= i;
  12.     }
  13.     return fakt;
  14. }
  15. int main()
  16. {
  17.     int n;
  18.     cin >> n;
  19.     cout << faktoriel(n) << endl;
  20.     return 0;
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment