# No Sevens

The next few challenges will involve loops, and this challenge can get you started.

The Kingdom of Zumbania recently banned the number 7. Please print all the numbers from 1 to 50 but skip all multiples of 7. Also, skip any number that has a 7 in it, such as `27`.

### Challenge

Print all the numbers as above, with each number on its own line.

Alternatively, you can try out Learneroo before signing up.

• #### Кирилл Варивода

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!

• #### Davin

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

• #### Learneroo

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

For finding out if the number ends with 7 you should check (number % 10) != 7

• #### Bernard Mitchell

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

• #### Bernard Mitchell

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

• #### Learneroo

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

• #### Bernard Mitchell

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

• #### Bolke

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

my code

• #### Bolke

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

• #### avisuisse

in R

for (i in 1:50) {

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

}

• #### Dheeraj Parmar

#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;
}
}
``````

}