将 'continue' 与模一起使用

Using 'continue' with modulo

我是 C# 编程的新手,请放轻松。

我找不到我的(很可能)简单的愚蠢问题的答案(没有愚蠢的问题!!)所以我 post 在这里。

我需要编写一个程序,使用 "continue" 指令显示 1 到 10 之间不能被 2、3 和 8 整除的数字。

我的代码:

static void Main(string[] args)
        {
            for (int i = 1; i <= 10; i++)
            {
                if (i % 2 == 0 && i % 3 == 0 && i % 8 == 0)  continue;
                Console.Write("{0} ", i);
            }
            Console.ReadKey();
        }

不过没用。主要问题是使用 &/&& 运算符。应该return 都是真的。帮助:(

I need to write a program which shows numbers from 1 to 10 that aren't divisble by 2, 3 and 8 using "continue" instruction.

可以除以 8 且没有余数的最小数是 8。因此 可以 限定的数字只有 8、9 或 10。

if (8 % 2 == 0 && 8 % 3 == 0 && 8 % 8 == 0) // false
if (9 % 2 == 0 && 9 % 3 == 0 && 9 % 8 == 0) // false
if (10 % 2 == 0 && 10 % 3 == 0 && 10 % 8 == 0) // false

None个数8、9、10可以除以2、3、8余数为0,所以当然所有个数会被打印出来,因为 continue 永远不会被触发。您确定是“2、3 和 8”而不是“2、3 或 8”吗?

if ((i % 2 == 0 && i % 3 == 0) || (i % 8 == 0))  continue;