代码搜索游戏01.14

squ*_*rel -2 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.
    }
}
Run Code Online (Sandbox Code Playgroud)
x    EXPECTED RESULT
--   ---------------
1    0
3    1
4    2
5    0
6    4
7    3
8    2
9    1
10   0
23   10
35   10
96   10

有帮助吗?

小智 7

public class Program {
    public static int Puzzle(int x) {
        return 10 % x;
    }
}
Run Code Online (Sandbox Code Playgroud)