1
Answer

there is error

jkjsha ahsa

jkjsha ahsa

15y
2.6k
1
here i want to make program get the perfect number
and there is a syntax error
i want to know

  static void Main(string[] args)
        {
            Console.WriteLine("enter ");
            int x = int.Parse(Console.ReadLine());
            bool p = perfect(x);
            if (p == true)
                Console.WriteLine("perfect");
            else
                Console.WriteLine("not perfect");

        }
        static bool perfect(int x)
        {
            int sum = 0;
            for (int i = 0; i <= x; i++)
            {
                sum += i;
                if (sum == x)
                    return true;
                else
                    if (sum > x)
                        return false;
            }
        }
the error
http://i34.tinypic.com/2ztltok.png
Answers (1)