Java 代码搜寻游戏01.14

Java 代码搜寻游戏01.14,java,algorithm,operators,Java,Algorithm,Operators,我目前正在玩一个输入参数“x”的游戏。我应该返回预期结果 public class Program { public static int Puzzle(int x) { // RETURN EXPECTED RESULT // Hint : You will have to use the modulo % operator to solve this one. } } x预期结果 -- --------------- 1 0 3

我目前正在玩一个输入参数“x”的游戏。我应该返回预期结果

public class Program {
    public static int Puzzle(int x) {
        // RETURN EXPECTED RESULT
        // Hint : You will have to use the modulo % operator to solve this one.
    }
}
x预期结果 -- --------------- 1 0 3 1 4 2 5 0 6 4 7 3 8 2 9 1 10 0 23 10 35 10 96 10 有什么帮助吗?

答案是: 返回10%x


也许其他人可以用数学术语解释为什么会这样。这一点我不能肯定。

你明白模运算符的作用吗?是的。我认为像f(x)%5这样的函数。。。
f(2)
应该是什么?我认为有人让你上了台-在
5
之前,结果是增加的,但之后是减少的(是的,在一个简单的
f(x)->x%5
)。重复的
10
s是怎么回事?
public class Program {
    public static int Puzzle(int x) {
        return 10 % x;
    }
}
public class Program {
    public static int Puzzle(int x) {
        return 10 % x;
    }
}