1
0
forked from kalmar/DALGLI0

Adds homework file

This commit is contained in:
void 2018-05-31 01:58:03 +02:00
parent 6ec94b66e5
commit b0dff74e04
5 changed files with 90 additions and 390 deletions

View File

@ -0,0 +1,90 @@
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());
}
}

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_9" default="false" project-jdk-name="10" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Homework/exersize1dommro1.iml" filepath="$PROJECT_DIR$/Homework/exersize1dommro1.iml" />
</modules>
</component>
</project>

View File

@ -1,365 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="34282eb7-2aeb-4c03-8360-f9b1e7d3a4b7" name="Default" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="Homework.java" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/Homework/src/Homework.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="15">
<caret line="11" selection-start-line="11" selection-end-line="11" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="EclideamAlgorithm.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/Homework/src/EclideamAlgorithm.java">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="31" selection-start-column="31" selection-end-column="31" />
<folding>
<element signature="e#1215#1216#0" expanded="true" />
<element signature="e#1252#1253#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings">
<option name="ROOT_SYNC" value="DONT_SYNC" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/Homework/src/EclideamAlgorithm.java" />
</list>
</option>
</component>
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsGulpfileManager">
<detection-done>true</detection-done>
<sorting>DEFINITION_ORDER</sorting>
</component>
<component name="NodePackageJsonFileManager">
<packageJsonPaths />
</component>
<component name="ProjectFrameBounds" fullScreen="true">
<option name="width" value="1366" />
<option name="height" value="768" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="PackagesPane" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="Homework" type="b2602c69:ProjectViewProjectNode" />
<item name="Homework" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="Homework" type="b2602c69:ProjectViewProjectNode" />
<item name="Homework" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="AndroidView" />
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="SearchEverywhereHistoryKey" value="git&#9;ACTION&#9;Git.Init" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="project.structure.last.edited" value="Modules" />
<property name="project.structure.proportion" value="0.15" />
<property name="project.structure.side.proportion" value="0.2" />
<property name="settings.editor.selected.configurable" value="vcs.Git" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/Homework/src" />
</key>
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration name="Unnamed" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="Homework" />
<module name="exersize1dommro1" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
</configuration>
<configuration default="true" type="Application" factoryName="Application">
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
</configuration>
<configuration default="true" type="JUnit" factoryName="JUnit">
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<patterns />
</configuration>
<configuration default="true" type="TestNG" factoryName="TestNG">
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="SUITE_NAME" />
<option name="PACKAGE_NAME" />
<option name="MAIN_CLASS_NAME" />
<option name="METHOD_NAME" />
<option name="GROUP_NAME" />
<option name="TEST_OBJECT" value="CLASS" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" />
<option name="WORKING_DIRECTORY" value="%MODULE_WORKING_DIR%" />
<option name="OUTPUT_DIRECTORY" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="singleModule" />
</option>
<option name="USE_DEFAULT_REPORTERS" value="false" />
<option name="PROPERTIES_FILE" />
<properties />
<listeners />
</configuration>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="34282eb7-2aeb-4c03-8360-f9b1e7d3a4b7" name="Default" comment="" />
<created>1527715254725</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1527715254725</updated>
<workItem from="1527715259721" duration="1750000" />
<workItem from="1527718938965" duration="64000" />
<workItem from="1527719048538" duration="1494000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="3308000" />
</component>
<component name="ToolWindowManager">
<frame x="0" y="0" width="1366" height="768" extended-state="0" />
<layout>
<window_info anchor="right" id="Palette" order="3" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="right" id="Palette&#9;" order="3" />
<window_info id="Image Layers" order="2" />
<window_info anchor="right" id="Capture Analysis" order="3" />
<window_info anchor="bottom" id="Event Log" order="7" side_tool="true" weight="0.32960895" />
<window_info anchor="right" id="Maven Projects" order="3" />
<window_info anchor="bottom" id="Database Changes" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Version Control" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Run" order="2" weight="0.32960895" />
<window_info anchor="bottom" id="Terminal" order="7" weight="0.32960895" />
<window_info id="Capture Tool" order="2" />
<window_info id="Designer" order="2" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.27086383" />
<window_info anchor="right" id="Database" order="3" />
<window_info id="Learn" order="2" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info id="UI Designer" order="2" />
<window_info anchor="right" id="Theme Preview" order="3" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="Messages" order="7" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Find" order="1" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/Homework/src/Homework.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165">
<caret line="11" selection-start-line="11" selection-end-line="11" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Homework/src/EclideamAlgorithm.java">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="31" selection-start-column="31" selection-end-column="31" />
<folding>
<element signature="e#1215#1216#0" expanded="true" />
<element signature="e#1252#1253#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Homework/src/Homework.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165">
<caret line="11" selection-start-line="11" selection-end-line="11" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Homework/src/EclideamAlgorithm.java">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="31" selection-start-column="31" selection-end-column="31" />
<folding>
<element signature="e#1215#1216#0" expanded="true" />
<element signature="e#1252#1253#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Homework/src/EclideamAlgorithm.java">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="31" selection-start-column="31" selection-end-column="31" />
<folding>
<element signature="e#1215#1216#0" expanded="true" />
<element signature="e#1252#1253#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Homework/src/Homework.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="15">
<caret line="11" selection-start-line="11" selection-end-line="11" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>
<state key="ArtifactsStructureConfigurable.UI">
<settings>
<artifact-editor />
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="FacetStructureConfigurable.UI">
<settings>
<last-edited>No facets are configured</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="GlobalLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="JdkListConfigurable.UI">
<settings>
<last-edited>10</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ModuleStructureConfigurable.UI">
<settings>
<last-edited>Homework</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
<option value="0.6" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>