What is wrong here?


  • 0
    G

    I am trying to find all primes less than x. I run program locally , it works fine. But here I keep getting following message.

    Last executed input : 6
    or
    Last executed input : 7
    or
    Last executed input : 8

    I am also not getting any prints from my C program . Can someone tell me what is wrong ?


  • 0
    R

    "Last executed input : 6" means value 6 didn't pass the test. If you upload your code and screenshot of the result, I can get more imformations.


  • 0
    C

    public class Solution {
    public int countPrimes(int n) {
    long counts = 0;
    if(n <= 2) return 0;
    for(int i=2; i < n; i++) {
    if(isPrime(i)) {
    counts++;
    }
    }
    return (int)counts;
    }

    public boolean isPrime(int t) {
        for(int j=2; j <= Math.sqrt(t); j++) {
            if(t%j == 0) return false;
        }
        return true;
    }
    

    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.