Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- long long silnia(int n) {
- if (n<1)
- return 1;
- return n*silnia(n-1);
- }
- int main () {
- int n;
- cout<<"Podaj liczbe: ";
- cin>>n;
- cout<<"Silnia z "<<n<<" wynosi: "<<silnia(n)<<endl;
- return 0;
- }
- -------------------------------------------------------------------------------------
- #include <iostream>
- using namespace std;
- long long wartosc(int n) {
- if (n==1)
- return -3;
- return wartosc(n-1)*4+(2*n);
- }
- int main () {
- int n;
- cout<<"Podaj liczbe: ";
- cin>>n;
- cout<<"Wartosc wynosi: "<<wartosc(n)<<endl;
- return 0;
- }
- -------------------------------------------------------------------------------------
- #include <iostream>
- using namespace std;
- long long wartosc(int n) {
- if (n==1) return -2;
- if (n==2) return 2;
- return wartosc(n-2)*wartosc(n-1);
- }
- int main () {
- int n;
- cout<<"Podaj liczbe: ";
- cin>>n;
- cout<<"Wartosc wynosi: "<<wartosc(n)<<endl;
- return 0;
- }
- -------------------------------------------------------------------------------------
- #include <iostream>
- using namespace std;
- void zamiana(int n) {
- if(n>0) {
- zamiana(n/2);
- cout<<n%2;
- }
- }
- int main () {
- int n;
- cout<<"Podaj liczbe: ";
- cin>>n;
- cout<<"Liczba "<<n<<" w postaci binarnej to: ";
- zamiana(n);
- cout<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment