0

My code returns this error:

ERROR! Unhandled Exception: StackOverflowException [ERROR] FATAL UNHANDLED EXCEPTION: System.StackOverflowException: The requested operation caused a stack overflow. at HelloWorld.x (System.Int32 y) <0x41e36180 + 0x00004> in <0e1357c43db845f2b6acb041d1724d28>:0 at HelloWorld.x (System.Int32 y) [0x00001] in <0e1357c43db845f2b6acb041d1724d28>:0 at HelloWorld.x (System.Int32 y) [0x00001] in <0e1357c43db845f2b6acb041d1724d28>:0 at HelloWorld.x (System.Int32 y) [0x00001] in at HelloWorld.x (System.Int32 y) [0x00001] in <0e1357c43db845f2b6acb041d1724d28>:0 at HelloWorld.x (System.Int32 y) [0x00001] in <0e1357c43db845f2b6acb041d1724d28>:0 at HelloWorld.x (System.Int32 y) [0x00001] in
[...]
<0e1357c43db845f2b6acb041d1724d28>:0 at HelloWorld.x (System.Int32 y) [0x00001] in <0e1357c43db845f2b6acb041d1724d28>:0 at HelloWorld.x (System.Int32 y) [0x00001] in <0e1357c43db845f2b6acb041d1724d28>:0 at HelloWorld.x (System.Int32 y) [0x00001] in <0e1357c43db845f2b6acb041d1724d28>:0 at HelloWorld.x (System.Int32 y) [0 etc...

I tried everything i swear and nothing worked.

My code:

using System;

public class HelloWorld

{
    static int x(int y)
    {
        return x(y)*x(y)+y;
    }

    public static void Main(string[] args)
    {
        Console.WriteLine (x(1));
    }
}
New contributor
AmiAmeliaAmelka is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.