SHARE
TWEET

Untitled

LeYe Feb 20th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6. int figurate(int num, int sides){
  7.     if (sides == 3){
  8.         if(num == 1){
  9.             return num;
  10.         }
  11.         else if(num>=2){
  12.             num + figurate(num-1,sides);
  13.         }
  14.     }
  15.     else if (sides == 4){
  16.         return num*num;
  17.     }
  18.     else if (sides == 5){
  19.         if(num == 1){
  20.             return num;
  21.         }
  22.         else if(num>=2){
  23.             num + 2*(num-1) + figurate(num-1,sides);
  24.         }
  25.     }
  26.     return -1;
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top