9/05/2011

What is a Recursive Call? and Make Fibonacci sequence function using Function of the Recursive Call type.

Recursive call is that this method call oneself.
Specially, Function uses this method.
Below C Source is example for recursive call function.
As you see, Function RF called the RF that is name of oneself.

Now I give you one question.
Please make Fibonacci sequence function using recursive call method.

You can see Fibonacci condition <here>

The LINUX that is name of OS is also recursive call type.
Some people said " LINUX is abbreviation of LINUX is not UNIX. "
Here, LINUX is call LINUX is not UNIX. In this sentence, LINUX is call LINUX is not UNIX again..
so..like that

(((((LINUX is not UNIX) is not UNIX) is not UNIX) is not UNIX) is not UNIX) is not UNIX

This case sink into the infinity roof because there is not escape condition. so we have to be careful when we use recursive call.

<English is very difficult.. Plz someone correct my poor sentence.>

์žฌ๊ท€ํ˜ธ์ถœ์ด๋ž€ ์ž๊ธฐ๊ฐ€ ์ž๊ธฐ์ž์‹ ์„ ํ˜ธ์ถœํ•˜๋Š” ๋ฐฉ์‹์„ ๋งํ•œ๋‹ค.
ํŠนํžˆ ํ•จ์ˆ˜์—์„œ ์ด๋Ÿฐ ์ผ์„ ํ•œ๋‹ค.
์ด๋Ÿฐ ์žฌ๊ท€ํ˜ธ์ถœ ํ•จ์ˆ˜๊ฐ€ ํ•„์š”ํ•œ ๊ฒฝ์šฐ๋Š”
์–ด๋–ค ์ผ์„ ํ•˜๋Š” ํ•จ์ˆ˜๊ฐ€ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ์กฐ๊ฑด์— ๋Œ€ํ•˜์—ฌ ๋˜‘๊ฐ™์€ ์ผ์„ ํ•  ํ•„์š”๊ฐ€ ์žˆ์„ ๋•Œ์ด๋‹ค.
๊ทธ๋Ÿฐ๋ฐ ๋‹ค์‹œ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ์กฐ๊ฑด์ด ์ฃผ์–ด์ง€๊ณ  ๋˜๋‹ค์‹œ ๊ฐ™์€ ์ผ์„ ํ•ด์•ผํ•  ๋•Œ ์žฌ๊ท€ ํ˜ธ์ถœ ํ•จ์ˆ˜๋ฅผ ์“ด๋‹ค.
์ด๊ฑด ๋ง๋กœ ํ‘œํ˜„ํ•˜๊ธฐ ๋ฌด์ฒ™ ์–ด๋ ต๋‹ค.. ใ…Žใ…Ž

ํ•œ๊ฐ€์ง€ ์˜ˆ์ œ๋ฅผ ๋ณด์ž

----------------------------------------------

int RF(int A);

void main()
{
printf("%d\n", RF(5) );
}


int RF(int A)
{
int B=0;
if(A>1)
{
B = RF(A-1);
}

return A+B;
}

------------------------------------------------

RFํ•จ์ˆ˜๋Š” 1์—์„œ ์ž…๋ ฅ๋œ ์ˆซ์ž๊นŒ์ง€ ๋”ํ•˜๋Š” ํ•จ์ˆ˜์ด๋‹ค.
RFํ•จ์ˆ˜๋ฅผ ๋ณด๋ฉด ๋ณธ๋ฌธ์•ˆ์— ๋‹ค์‹œ ์ž๊ธฐ ์ž์‹ ์„ ํ˜ธ์ถœํ•˜๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.
์ด๋Ÿฐ ๋ฐฉ๋ฒ•์„ ์žฌ๊ท€ํ˜ธ์ถœ์ด๋ผ๊ณ  ํ•œ๋‹ค.

์—ฌ๊ธฐ์„œ ๋ฌธ์ œ๊ฐ€ ๋‚˜๊ฐ‘๋‹ˆ๋‹ค.
์ด๋Ÿฐ ์žฌ๊ท€ํ˜ธ์ถœ ๋ฐฉ์‹์„ ์ด์šฉํ•˜์—ฌ ํ”ผ๋ณด๋‚˜์น˜ ์ˆ˜์—ด์˜ ๊ฐ’์„ ๊ตฌํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ๊ตฌํ˜„ํ•ด ๋ณด์‹œ์˜ค.
์ด๋ฒˆ์—๋Š” ์ข€ ์–ด๋ ค์šธ ๊ฑธ.. ใ…‹ใ…‹


์ด๋Ÿฐ ๊ฒƒ๋„ ์žฌ๊ท€ ํ˜ธ์ถœ์ผ๊นŒ?
LINUX ๋ผ๋Š” ์šด์˜์ฒด์ œ๊ฐ€ ์žˆ๋‹ค.
๊ทธ๋Ÿฐ๋ฐ ์ด๊ฒƒ์€ LINUX is not UNIX์˜ ์•ฝ์ž๋ผ๊ณ  ํ•œ๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ์—ฌ๊ธฐ์„œ LINUX๋Š” ๋‹ค์‹œ LINUX is no UNIX๋ฅผ ๋งŒ๋“ ๋‹ค.

๋”ฐ๋ผ์„œ ..
(((((LINUX is not UNIX) is not UNIX) is not UNIX) is not UNIX) is not UNIX) is not UNIX

LINUX is not UNIX์—์„œ LINUX๊ฐ€ ๊ณ„์† LINUX is not UNIX๋ฅผ ์ƒ์„ฑํ•ด ๋‚ธ๋‹ค..
์ด๋ ‡๋“ฏ ์žฌ๊ท€ํ˜ธ์ถœ์€ ์กฐ๊ฑด ๋ฌธ์œผ๋กœ break๋ฅผ ์ž˜ ํ•ด์ฃผ์ง€ ์•Š์œผ๋ฉด ๋ฌดํ•œ ๋ฃจํ”„์— ๋น ์ง€๊ธฐ ์‰ฝ๋‹ค..