used match ( PEP 636 )
To run script you need python >=3.10
You can run the script from the command-line using
python _power.py
Used math formula
a ≅ b (mod m)
Find the remainder from dividing:
As a result, we must convert the power of
Additionaly,
The first line of the input gives state of program output:
0 - Limit On | 1 - Limit off | 2 - Debug + Limit on | 3 - Debug only
The second line gives the number of test cases,
In program A = given_int; P = power; M = modulus
With this parameter, we can specify whether the program should stop at -1 / 1 or continue with the given power.
For each test case, output the first line containing Case #x: y, where x is the test case number (starting from 1) and y is a list that contains dictionary with possible replacable equations.
Output format
<give_int>^<power> ≅ <result_number> (mod M)
2
1
7 10 100
2
- state 2 1
- number of test cases
7
- given 10
- given 100
- given
[DEBUG] operation: - power: 3 old: 343 new: 243
[DEBUG] operation: - power: 3 old: 243 new: 143
[DEBUG] operation: - power: 3 old: 143 new: 43
[DEBUG] operation: - power: 4 old: 301 new: 201
[DEBUG] operation: - power: 4 old: 201 new: 101
[DEBUG] operation: - power: 4 old: 101 new: 1
Case #1: [{'7^1 ≅ 7 (mod 100)'}, {'7^2 ≅ 49 (mod 100)'}, {'7^3 ≅ 43 (mod 100)'}, {'7^4 ≅ 1 (mod 100)'}]