lab3 - 1. #include int Tfunction(int a) cfw_ if...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 #include<cmath> int Tfunction(int a) { if (a==0) { return 0 } else { return (Tfunction(a-1)+1) } } int Qfunction(int a) { if (a==0) { return 0 } else { return (Qfunction(a-1)+a) } } int Rfunction(int a) { if(a==0) { return 0 } else { return (2*Rfunction(a-1)+1) } } int Xfunction(int a) { if(a==0) { return 0 } else { return (2*Xfunction(a/2)+1) } } int Yfunction(int a)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Page 2 { if(a==0) { return 0 } else { return (2*Yfunction(a/2)+a) } } int Zfunction(int a) { if(a==1) { return 0 } else { return (Zfunction(sqrt(a))+1) } } int main(void) { int n ostream output("results.txt") for (n = 10 { cout << n<<","<< T(n) <<","<< Q(n) << "," << X(n) <<"," << Y(n)<<","<< Z(n) << "\n" output << n<<","<< T(n) <<","<< Q(n) << "," << X(n) <<"," << Y(n)<<","<< Z(n) << "\n" } exit(1) } 2. R(1)=1 R(2)=3 R(3)=7 R(4)=15 R(5)=31 R(6)=63 R(7)=127 R(8)=255 R(9)=511 R(10)=1023 R(11)=2047 R(12)=4095 R(13)=8191 R(14)=16383 R(15)=32767 The number would've taken up too much memory to do by 10's up to 1000. sigma(k=1,i) (2(i-1)+1)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/20/2011 for the course ECON 1110 taught by Professor Person during the Spring '11 term at Rensselaer Polytechnic Institute.

Page1 / 10

lab3 - 1. #include int Tfunction(int a) cfw_ if...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online