Presentation is loading. Please wait.

Presentation is loading. Please wait.

R E C U R S I O N Legaspi, Ma. ArleneProf. Carmela Francisco MITSAT 8:00 am to 4pm.

Similar presentations


Presentation on theme: "R E C U R S I O N Legaspi, Ma. ArleneProf. Carmela Francisco MITSAT 8:00 am to 4pm."— Presentation transcript:

1 R E C U R S I O N Legaspi, Ma. ArleneProf. Carmela Francisco MITSAT 8:00 am to 4pm

2 3.4 Recursion Recur From the Latin, re- = back + currere = to run, To happen again, esp at repeated intervals. An algorithmic technique where a function, in order to accomplish a task, calls itself with some part of the task.

3 3.4.1 Recursive functions Many mathematical functions can be defined recursively: Factorial Fibonacci Euclid's GCD (greatest common denominator) Fourier Transform

4 Factorial In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n.mathematicsnon-negative integerproduct

5 Fibonacci the Fibonacci numbers are the following sequence of numbers:sequence The first two Fibonacci numbers are 0 and 1, and each remaining number is the sum of the previous two:Fibonacci

6 Euclid's GCD (greatest common denominator) In mathematics, the Euclidean algorithm [a] is an efficient method for computing the greatest common divisor (GCD). The algorithm is also called Euclid's algorithm, after the ancient Greek mathematician Euclid, who first described it.mathematics [a]greatest common divisormathematicianEuclid The GCD of two numbers is the largest number that divides both of them without leaving a remainder.remainder For example, 21 is the GCD of 252 and 105 (252 = 21 × 12, 105 = 21 × 5), which is the same as the GCD of 147 and 105, since 252 − 105 = 147.

7 In mathematics, the Fourier transform is an operation that transforms one complex-valued function of a real variable into another. The new function, often called the frequency domain representation of the original function, describes which frequencies are present in the original function.mathematics transformscomplexfunctionreal variablefrequency domain for every real number x.

8 #include void add() { float a, b, sum; cout<<"Enter the first number: "; cin>>a; cout<<"Enter the second number: "; cin>>b; sum = a + b; cout<<"The sum of two numbers is "<<sum; getch(); } int main() { add(); }

9

10 Untitled Document //put your text here var theText = “Data Structure"; function nextSize(i,incMethod,textLength) { if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) ); if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14)))); }

11 function sizeCycle(text,method,dis) { output = ""; for (i = 0; i < text.length; i++) { size = parseInt(nextSize(i +dis,method,text.length)); output += " " +text.substring(i,i+1)+ " "; } theDiv.innerHTML = output; } function doWave(n) { sizeCycle(theText,1,n); if (n > theText.length) {n=0} setTimeout("doWave(" + (n+1) + ")", 50); }

12

13

14 E N D


Download ppt "R E C U R S I O N Legaspi, Ma. ArleneProf. Carmela Francisco MITSAT 8:00 am to 4pm."

Similar presentations


Ads by Google