Академический Документы
Профессиональный Документы
Культура Документы
Calculate f(xi )
B Point B=(xi,f(xi))
Draw the tangent to f(x)
C= intercept on x axis
C=(xi+1,0)
C A f'(xi) = derivative
xi+1 xi = (d f(x))/dx at xi
f(x) ≈ AB/AC
xi = (xi + y/xi)/2;
float xi=1;
xi = (xi + y/xi)/2 ;
int a=36,b=24;
cout << gcd(a,b) << endl; copy values of a and b
into m and n
store n in a
return value
cout << gcd(99,47)<< endl; a=36, b =24 area
} Activation frame of main
Function Execution
int gcd(int m, int n) { • Activation frame: area in
while(m % n != 0){ memory where function
int r = m%n; variables are stored
m = n;
n = r;
}
return n;
}
main_program{
int a=36,b=24;
gcd activation frame is destroyed
cout << gcd(a,b) << endl;
cout << gcd(99,47)<< endl;
} a=36, b =24 returned value of n
Activation frame of main
How A Function Executes
LCM(m,n) = m*n/GCD(m,n)
return m*n/gcd(m,n);