Ad
  • Custom User Avatar

    You need not to go up to _n / 2 to check whether a number is a prime.

    Also, the hash is useless in this regard, the isprime and loop are sufficient to solve it!

  • Custom User Avatar

    OP solved it, closing

  • Default User Avatar

    n is of type int so your cast to long long has no effect since it is downcasted to int again immediately. Thus you are only doing int-calculations in your return statement. Assign the long long to a new variable and it will work.

  • Custom User Avatar

    what could I be doing wrong?

    Anything? If your code crashes, then your memory handling must be wrong.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    tried it as well,
    dont know why i still get the error message:

    main.cpp:193:9: error: invalid operands to binary expression ('stringstream' (aka 'basic_stringstream') and 'X')
    out << X();
    ~~~ ^ ~~~
    /usr/include/c++/v1/ostream:191:20: note: candidate function not viable: no known conversion from 'X' to 'std::__1::basic_ostream &()(std::__1::basic_ostream &)' for 1st argument
    basic_ostream& operator<<(basic_ostream& (
    __pf)(basic_ostream&));

  • Custom User Avatar

    Segfault.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    I have the same problem, in c lang the last test crashes

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    in c language, i pass all the test but last one crashes,

    i get this error code:
    "Test Crashed
    Exit code: 0
    Signal code: 6"

    what could i be doiing wrong?

  • Default User Avatar

    Using RegEx should be cheating... ;)

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Tests for 1 and 10 are successful, but test for 40 comes out wrong:
    right answer is 1.4788962720000001 , but got: 1.4235528840000000.

    any idea why can it be?

  • Loading more items...