Advertisement
rotti321

Iasi 2019 SI 2c

Nov 2nd, 2021
573
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int F(int n,int t){
  5.    if(n==0) return 0;
  6.  
  7.    if(n%2==0)
  8.         return F(n/2,t*2)+t;
  9.     else
  10.         return F(n/2,t*2);
  11.    
  12. }
  13. int main() {
  14.     int n,p=1;
  15.     cin >> n;
  16.     cout<<F(n,1);
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement