【问题标题】:How to calculate the expression如何计算表达式
【发布时间】:2017-06-19 04:18:25
【问题描述】:

给定方程-> (index+rotation)%rot=f;如果我知道 f , rotation , rot 的值 计算指数的公式是什么。我的数学不太好,但我想知道在我的编程中计算指数。

【问题讨论】:

  • rot*k+f - rotation,这里k是一个非零整数。

标签: math modular-arithmetic


【解决方案1】:

(索引 + 旋转)%rot = f

意思

index + rotation = rot*k + f, k is an integer (.., -2, -1, 0, 1, 2,..)

所以

index = rot*k + f - rotation, k: integer

如果你想拥有index > 0,请务必选择k > (rotation - f) / rot

【讨论】:

    猜你喜欢
    • 2017-06-28
    • 1970-01-01
    • 1970-01-01
    • 2014-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多