This commit is contained in:
DH10RBH 2024-04-16 11:33:30 +02:00
parent 7881c5b11f
commit c5b526ec44
7 changed files with 108 additions and 0 deletions

29
Kontrollstrukturen/afg3 sieb/.gitignore vendored Normal file
View File

@ -0,0 +1,29 @@
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

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

View File

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

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>

View File

@ -0,0 +1,11 @@
<?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

@ -0,0 +1,40 @@
import java.util.Arrays;
public class Main {
// =====================
// Sieb des Erathostenes (kopiert von Matti)
// =====================
public static void main(String[] args){
int MAXIMUM = 100;
int MAX_PER_ROW = 20;
boolean[] primes = new boolean[MAXIMUM];
Arrays.fill(primes, true);
for(int i=2; i < MAXIMUM * 0.5; i++){
for(int j=2; j < MAXIMUM; j++){
int index = i * j;
if(index < MAXIMUM && index > 0){
primes[index] = false;
}
}
}
int counter = 0;
for(int i=0; i < primes.length; i++){
if(primes[i] && i > 1) {
System.out.print(i + " ");
counter++;
if (counter % MAX_PER_ROW == 0) {
System.out.println();
}
}
}
}
}