Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication12;
- public class JavaApplication12 {
- public static void main(String[] args) {
- //for (int i = 2; i < szamok().length; i++) {
- // System.out.print(szamok()[i] + " ");
- // }
- //System.out.println();
- harmadik();
- masodikCsokken();
- oszthato();
- }
- public static int[] szamok() {
- int[] szam = new int[34];
- szam[0] = 1;
- szam[1] = 2;
- for (int i = 2; i < 34; i++) {
- szam[i] = szam[i - 2] + szam[i - 1];
- }
- return szam;
- }
- public static void harmadik() {
- System.out.print("A sorozat minden 3. szama: ");
- for (int i = 2; i < szamok().length; i += 3) {
- System.out.print(szamok()[i] + " ");
- }
- }
- public static void masodikCsokken() {
- System.out.println();
- System.out.print("A sorozat minden 2. szama csokkeno sorrendben: ");
- for (int i = szamok().length - 1; i >= 0; i -= 2) {
- System.out.print(szamok()[i] + " ");
- }
- }
- public static void oszthato() {
- System.out.println();
- for (int i = 4; i < szamok().length; i += 5) {
- if (szamok()[i] % 4 == 0) {
- System.out.print("neggyel oszthato a " + szamok()[i]);
- System.out.println();
- } else {
- System.out.print("nem oszthato neggyel a " + szamok()[i]);
- System.out.println();
- }
- if (szamok()[i] % 6 == 0) {
- System.out.print("hattal oszthato a " + szamok()[i]);
- System.out.println();
- } else {
- System.out.print("nem oszthato hattal a " + szamok()[i]);
- System.out.println();
- }
- if (szamok()[i] % 12 == 0) {
- System.out.print("tizenkettovel oszthato a " + szamok()[i]);
- System.out.println();
- } else {
- System.out.print("nem oszthato tizenkettovel a " + szamok()[i]);
- System.out.println();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement