jkjsha ahsa

jkjsha ahsa

  • NA
  • 24
  • 26.1k

there is error

Nov 6 2009 11:48 AM
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)