first commit

This commit is contained in:
2022-12-07 10:06:14 +01:00
commit 7acee63be6
40 changed files with 433 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,58 @@
package Ueb07;
import java.util.*;
class Teileranzahl{
static int in = 0, counter = 0, highest = 1,tmp;
static Scanner sc;
public static void main( String[] args){
do{
System.out.println("------------------------------------------------------------------------------");
System.out.println("1 Teileranzahl für n");
System.out.println("2 Maximale Teileranzahl für die Zahlen 1 bis n");
System.out.println("3 Fertig");
System.out.println("------------------------------------------------------------------------------");
sc = new Scanner(System.in);
in = sc.nextInt();
}while(!(in==1||in==2||in==3));
switch(in){
case 1:
sc = new Scanner(System.in);
in = sc.nextInt();
System.out.println(anzahlTeiler(in));
break;
case 2:
sc = new Scanner(System.in);
in = sc.nextInt();
tmp = maxTeiler(in);
System.out.println(tmp);
System.out.println(anzahlTeiler(tmp));
break;
case 3:
return;
}
sc.close();
}
public static int anzahlTeiler(int input){
counter = 0;
for(int i=1; i<=in;i++){
if(input%i==0){
counter++;
}
}
return counter;
}
public static int maxTeiler(int input){
for(int i=1;i<input;i++){
if(anzahlTeiler(i) > anzahlTeiler(highest)){
highest = i;
}
}
return highest;
}
}