Search:

Type: Posts; User: javapenguin

Search: Search took 0.06 seconds.

  1. Replies
    3
    Views
    4,406

    Re: Method returning boolean

    Ohhhh, non-prime numbers also would have that factor.

    Have a for loop that starts at 3


    public static boolean isPrime(int num)
    {

    if (num <=1)
    return false;
  2. Replies
    3
    Views
    4,406

    Re: Method returning boolean

    if(num%1==0 && num%num==0)

    num%1 means the remainder of num/1 which is 0.

    num/num = 1 with remainder 0.

    Always true unless perhaps num = 0;
Results 1 to 2 of 2