Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- long long factorial(int);
- int main()
- {
- int number;
- std::cout << "W tym programie wyliczymy silnie. Podaj liczbe(ostrzezenie: silnia bedzie duza, wiec zaleca sie nie uzywanie zbyt duzych liczb): \n";
- for(;;)
- {
- std::cin >> number;
- if(!std::cin)
- break;
- std::cout << "Silnia z liczby " << number << " wynosi " << factorial(number) << ". \n";
- std::cout << "Podaj kolejna liczbe lub podaj litere aby zakonczyc.\n";
- std::cin.clear();
- }
- return 0;
- }
- long long factorial(int number)
- {
- if(number == 1)
- return 1;
- else
- return number * factorial(number - 1);
- }
Advertisement
Add Comment
Please, Sign In to add comment