Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Can't use Factorial method

$
0
0

New user here, i'll explain quickly the issue

When creating a console program, I tried to use this method inside the static void main

   int Factorial(int i)
            {if (i <= 1)
                    return 1;
                    return i * Factorial(i - 1);
            }

to calculate the factorial of a number.

But as soon as I finished typing it, the compiler gives an error that occur in the void main's curly braces.

I already tried to set the method to public/static/public static

Please give detailed explanation, thanks in advance


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>