Prime Number Formula

前端 未结 13 1596
情话喂你
情话喂你 2020-12-06 08:47

I am trying to write a prime number function in C# and I am wondering if the follow code will work. It \"appears\" to work with the first 50 numbers or so. I just want to ma

13条回答
  •  执笔经年
    2020-12-06 09:16

    this is a simple one

    only odd numbers are prime....so

    static bool IsPrime(int number)
    {
    int i;
    if(number==2)
        return true;                    //if number is 2 then it will return prime
    for(i=3,i

提交回复
热议问题