[ create a new paste ] login | about

Link: http://codepad.org/U2dOkNvB    [ raw code | output | fork ]

C++, pasted on Sep 17:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <cmath>
#include <iostream>
using namespace std;

size_t power2(size_t n);

int main(){
    cout<<pow(2.0, 5.0)<<" "<<power2(5)<<endl;
    cout<<pow(2.0, 17)<<" "<<power2(17)<<endl;
    return 0;
}


size_t power2(size_t n){
    if( n )
    return 2 << (n - 1);
    else
    return 1;
}


Output:
1
2
32 32
131072 131072


Create a new paste based on this one


Comments: