Using the following values: x = 2386073 n = 2 p = 2147483647 The expected value of xⁿ mod p is 365213132: 2386073 x 2386073 = 5693344361329 ⌊ 5693344361329 ÷ 2147483647 ⌋ = 2651 2651 x 2147483647 = 5692979148197 5693344361329 - 5692979148197 = 365213132 however llModPow is incorrectly returning 365210482 Using https://www.emathcalculator.com/en/calculators/algebra/powerMod.php confirmed my long-hand calculation gave the correct result. These are not the only values that give incorrect results (e.g. x=149120, with same n and p should return 761937930 but llModPow returns 761937910). It does seem in my limited testing that llModPow gives wrong results when x² is larger than a 32bit integer. You can check llModPow with the following script: default { state_entry() { integer x = 2386073; integer n = 2; integer p = 2147483647; integer expected = 365213132; integer result = llModPow(x, n, p); llSay(0, llList2CSV([ "x", x, "n", n, "p", p ])); llSay(0, llList2CSV([ "expected", expected, "actual", result ])); } } Change x, n, p and expected as appropriate. ETA: Above details were posted in non-public fields, oops.