Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int F(int n,int t){
- if(n==0) return 0;
- if(n%2==0)
- return F(n/2,t*2)+t;
- else
- return F(n/2,t*2);
- }
- int main() {
- int n,p=1;
- cin >> n;
- cout<<F(n,1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement