Is It Prime? Getting WrongAnswer

Dev Skill archived problems can be discussed here.

Is It Prime? Getting WrongAnswer

by sebu » Mon Sep 26, 2016 3:45 pm

This is My First Problem, i have submitted in devskill. in .net compiler this running ok, but getting error in devskill, where is the wrong answer.

Code: Select all
public static void Main()
        {
            var testCase = int.Parse(Console.ReadLine());
            var T=0;
            if (T <= 5000)
            {
                T = testCase;
            }

           
            var inputValues= new int[T];
            for (var i = 0; i < T; i++)
            {
                var number = int.Parse(Console.ReadLine());
                if (number >= 0 && number <= 10000)
                {
                    inputValues[i] = number;
                }
            }

           
            foreach (var item in inputValues)
            {
                Console.WriteLine(IsPrime(item));
            }

            Console.ReadKey();
        }

        public static string IsPrime(int number)
        {
            var flag = 0;
            for (var i = 2; i < number; i++)
            {
                if ((number%i) == 0)
                {
                    flag = 0;
                    break;
                }
                flag = 1;
            }
            return flag == 1 ? "Yes" : "No";
        }
 
Posts: 4
Joined: Mon Sep 26, 2016 3:40 pm

Re: Is It Prime? Getting WrongAnswer

by devskill » Tue Sep 27, 2016 10:49 pm

Please always format code while posting.

Try following:

Input:
Code: Select all
3
2
3
5


Output:
Code: Select all
Yes
Yes
Yes
User avatar
Site Admin
 
Posts: 118
Joined: Tue Feb 02, 2016 10:24 pm

Re: Is It Prime? Getting WrongAnswer

by sebu » Wed Sep 28, 2016 10:30 am

Thanks for the reply. i got a new model to learn, participate, taking challenge, problem solving area, hope devskill.com will reach at top point very soon.
 
Posts: 4
Joined: Mon Sep 26, 2016 3:40 pm

Re: Is It Prime? Getting WrongAnswer

by devskill » Wed Sep 28, 2016 10:05 pm

Thank you.
User avatar
Site Admin
 
Posts: 118
Joined: Tue Feb 02, 2016 10:24 pm


Who is online
Users browsing this forum: No registered users and 1 guest
cron