Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
42 | daniel-mar | 1 | package de.viathinksoft.immortal.bases; |
2 | |||
3 | import java.util.Vector; |
||
4 | |||
5 | public class SearchRoots { |
||
6 | |||
7 | public static boolean isImmortal(int num, int base) { |
||
8 | String quadrat = "" + PowMod.powmod(num, 2, base); |
||
9 | return (quadrat.endsWith("" + num)); |
||
10 | } |
||
11 | |||
12 | private static void checkBase(int b) { |
||
13 | Vector<String> roots = new Vector<String>(); |
||
14 | |||
15 | for (int i = 0; i < b; i++) { |
||
16 | |||
17 | if (isImmortal(i, b)) { |
||
18 | roots.add("" + i); |
||
19 | } |
||
20 | } |
||
21 | |||
22 | System.out.println("Base " + b + ": " + roots); |
||
23 | } |
||
24 | |||
25 | public static void main(String[] args) { |
||
26 | for (int i = 1; i < 255; i++) { |
||
27 | checkBase(i); |
||
28 | } |
||
29 | } |
||
30 | |||
31 | } |