12345678910111213141516171819202122232425262728 |
- package prak1;
-
- public class Main {
- public static void main(String[] args) {
-
- int loopLength = 200;
- if (args != null && args.length != 0) {
- loopLength = Integer.parseInt(args[0]);
- }
-
- int previousValue = 0;
- for (int i = 0; i <= loopLength; i++) {
- if (i == 0) {
- continue;
- } else if (i % 5 == 0) {
- System.out.println(i + " ist durch 5 teilbar!");
- } else if (Integer.toString(i).endsWith("9")) {
- System.out.println(i + " endet auf 9!");
- } else if ((i + previousValue) % 3 == 0) {
- int res = i + previousValue;
- System.out.println(i + " und " + previousValue + " addiert ergeben " + res + " und " + res + " ist durch 3 teilbar.");
- }
-
- previousValue = i;
- }
- }
-
- }
|