Rekursif : Example Programs with Recursive Multiplication (Contoh Program Perkalian dengan Rekursif)
Recursive means that a process can call itself. Recursive definition is actually contained in the procedures and functions. The difference is that the recursive call to itself can be, but the procedures and functions must be called by the caller procedures and functions. Recursive programming techniques are important and some programming languages support the existence of this recursive process. In procedures and functions, the call to itself can mean an iterative process that can not be known when it will end.
Now I will make an example of multiplication program (axb = a + a + a +...+ a total b times) by using recursive. Multiplication recursively can be written as follows :
(a x b) = a + a +...+a (sebanyak b kali)
(a x b) = a + (a x (b-1))
that programming can be written as
kali(a,b) = a + (kali(a, (b-1)))
We can make a recursive function as follows :
For complete program can be downloaded at dyas sembilanpoeloeh
Hopefully helpful friend..
Jadilah yang pertama mengomentari
Post a Comment