κ°„λ‹¨ν•˜κ²Œ 예제λ₯Ό λ§Œλ“€μ–΄λ³΄λ©΄


class Main

{

public static int A (int a,int b)

{

console.WriteLine($"a + b: {result}");


if(a

int result = a + b;

return result;

else

return A(a + b) + A(a - b);

}


class MainApp

{

public static void Main(string[] args)

{

int x = 1;

int y = 2;


int result = Main.A(x.y);

}


λ§Œμ•½ 두 개의 λ³€μˆ˜λ₯Ό ν•©μΉ˜λŠ” μ½”λ“œλ₯Ό λ©”μ˜λ“œλ‘œ λ¬Άμ–΄μ„œ μ‹€ν–‰ν•œλ‹€λ©΄ a = 1,x = 1,b = 2,y =2 이처럼 λ©”λͺ¨λ¦¬ 4개λ₯Ό μ‚¬μš©ν•˜μž–μ•„.

이게 계산식이 λ³΅μž‘ν•΄μ§€κ³  κΈΈμ–΄μ§ˆμˆ˜λ‘ Main λ©”μ˜λ“œμ— x,yλ³€μˆ˜κ°€ int A λ©”μ˜λ“œμ— "볡사"λ˜λŠ” κ±°κΈ°λ•Œλ¬Έμ— λ©”λͺ¨λ¦¬μ‚¬μš©λŸ‰μ΄ λŠ˜μ–΄λ‚˜λŠ”κ±΄ μ•Œκ² λŠ”λ°

이게 κ²Œμž„μ— 영ν–₯을 κ°ˆμ •λ„λ‘œ λ©”λͺ¨λ¦¬μ‚¬μš©λŸ‰μ΄ 심해짐? μ•„λ‹ˆλ©΄ μ½”λ“œκ°€ λŠ˜μ–΄μ§€λ”λΌλ„ κ°œλ³„μ μœΌλ‘œ μ λŠ”κ²Œ λ‚˜μŒ?