Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- // korisnikot vnesuva eden broj n, treba da napiseme funkcija koja ke ni go vraka faktorielot od toj broj
- int faktoriel(int broj) {
- //5! = 5 * 4 * 3 * 2 * 1 = 120
- //6! = 120 * 6
- //7! 720 * 7 = 5040
- int fakt = 1;
- for(int i = 1; i <= broj; i++) {
- fakt *= i;
- }
- return fakt;
- }
- int main()
- {
- int n;
- cin >> n;
- cout << faktoriel(n) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment