I am trying to rewrite the following piece of java code to python:
class pcp {
public static void main(String[] args) {
final int b = 13;
final int m = 1000;
int a0 = 1;
int mas[] = new int[10];
int a = a0, T = 0;
do {
System.out.print(a + " ");
a = (b * a) % m;
T++;
mas[a * 10 / m]++;
} while (a != a0);
System.out.print("\n" + T + "\n");
for (int i = 0; i < mas.length; i++)
System.out.print(mas[i] + " ");
}
}
It's a simple pseudo random number generator with the following output:
1 13 169 197 561 293 809 517 721 373 849 37 481 253 289 757 841 933 129 677 801 413 369 797 361 693 9 117 521 773 49 637 281 653 489 357 641 333 329 277 601 813 569 397 161 93 209 717 321 173 249 237 81 53 689 957 441 733 529 877 401 213 769 997 961 493 409 317 121 573 449 837 881 453 889 557 241 133 729 477 201 613 969 597 761 893 609 917 921 973 649 437 681 853 89 157 41 533 929 77
100
11 9 11 9 11 9 11 9 11 9
Here's my Python code:
b = 13
m = 1000
a0 = 1
mas = [0] * 10
a = a0
T = 0
while not (a != a0):
print(a)
a = (b * a) % m
T = T + 1
mas[int(a * 10 / m)] = mas[int(a * 10 / m)] + 1
print(T)
i = 0
while (i < len(mas)):
print(mas[i])
i = i + 1
It simply won't enter the loop an I'm kinda at loss about how rewrite it in the correct way for python.
Thank you for reading and your help.