No Sevens Comments

Comments

  • I can't even imagine using mod operator "to see if a number ends in 7". Web search didn't helped too.
    Also, I do not see a reason to check if number divides by 7.

  • I do not see a reason to check if number divides by 7.

    I got it.Then I put my code and it all works. It's just a mess of statements.
    Now I see Explanation below, it's so easy now using only one if statement!

  • This is weird for me, it works until the number 14. How can it be the case?

  • @Davin, for specific feedback from admins on your code, consider signing up for membership or the bootcamp.

  •     for(int i = 1; i < 51; i++){
            if(i%7==0){}//skip multiple of 7
            else if(i > 10 && (i%10)==7){} //skip ends with 7
            else {
            System.out.println(i);}
            }
    
  • For finding out if the number ends with 7 you should check (number % 10) != 7

  • What is the correct phrasing for the print function. I keep getting an error when trying to test my code? Thanks

  • I keep getting errors in part of the code that I'm not altering. Can I please get some help on this? Thanks

  • This usually means you've changed the boilerplate code. In such a case, carefully copy your actual code, click "reset" and try again.

  • I keep getting an "cant find symbol error" when I try to print my int.. I'm going to have to cheat on this one. sigh

  • I think I would like to get recognition for possibly having devised the longest, clunkiest and ugliest answer so far:

    my code

  • Ha, now I see the pitiful 3 lines of code given as the official answer...That won't cut it.
    [insert smiley emoticon here.]

  • in R

    for (i in 1:50) {

    if (i == 7) {
    next
    }
    else if (i %% 10 == 7) {
    next
    }
    else print(i)

    }

  • #include

    using namespace std;

    int main()
    {

    for(int i=0;i<=50;i++)
    {
        if( (i==7) || (i%7==0) || (i%10==7) )
        {
            continue;
    
        }
        else{
            cout<<i<<endl;
        }
    }
    

    }

Contact Us
Sign in or email us at [email protected]