91 lines
2.5 KiB
Java
91 lines
2.5 KiB
Java
import java.util.Scanner;
|
|
import java.util.Vector;
|
|
|
|
public class Homework {
|
|
|
|
private int input;
|
|
private Vector<String> output;
|
|
private Vector<Integer> zeroDevisors;
|
|
private Vector<Integer> units;
|
|
private Vector<Integer> nilpotents;
|
|
private Vector<Integer> idempotents;
|
|
|
|
Homework(int input) {
|
|
this.input = input;
|
|
output = new Vector<>();
|
|
zeroDevisors = new Vector<>();
|
|
units = new Vector<>();
|
|
nilpotents = new Vector<>();
|
|
idempotents = new Vector<>();
|
|
calculateHomework();
|
|
}
|
|
|
|
public String getOutput() {
|
|
return output.toString();
|
|
}
|
|
|
|
private void calculateHomework() {
|
|
calculateUnits();
|
|
calculateZeroDevisors();
|
|
calculateNilpotents();
|
|
calculateIdempotents();
|
|
|
|
output.add(units.toString());
|
|
output.add(zeroDevisors.toString());
|
|
output.add(nilpotents.toString());
|
|
output.add(idempotents.toString());
|
|
}
|
|
|
|
private void calculateUnits() {
|
|
for (int element = 1; element < input; element++) {
|
|
EclideamAlgorithm eclideamAlgorithm = new EclideamAlgorithm(element,input);
|
|
if ( eclideamAlgorithm.getGCD() == 1) {
|
|
units.add(element);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
private void calculateZeroDevisors() {
|
|
zeroDevisors.add(0);
|
|
for (int element = 1; element < input; element++) {
|
|
for (int numberB = 1; numberB < input; numberB++) {
|
|
if ((element * numberB) % input == 0) {
|
|
zeroDevisors.add(element);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void calculateNilpotents() {
|
|
nilpotents.add(0);
|
|
for (int number = 1; number < input; number++) {
|
|
int temporary = number;
|
|
for (int power = 2; power < input; power++) {
|
|
temporary = temporary * number;
|
|
if ((temporary) % input == 0) {
|
|
nilpotents.add(number);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void calculateIdempotents() {
|
|
idempotents.add(0);
|
|
for (int number = 1; number < input; number++) {
|
|
if ((number * number) % input == number) {
|
|
idempotents.add(number);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void main(String[] arg) {
|
|
Scanner scanner = new Scanner(System.in);
|
|
int input = scanner.nextInt();
|
|
Homework homework = new Homework(input);
|
|
System.out.println(homework.getOutput());
|
|
}
|
|
}
|