Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.3 kB
2
Indexable
Never
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

public class Main {
    public static void main(String[] args) {
        interface MyInterface
        {
            public List<Integer> getSequence();
            public List<Integer> getAllDivisors();
            public List<Integer> getAllEasyDivisors();
            public int[] getMostFrequentNumbers();
        }

        class MyClass implements MyInterface
        {
            final int a;
            final int b;

            public MyClass(int a, int b)
            {
                this.a = a;
                this.b = b;
            }

            @Override
            public List<Integer> getSequence() {
                List<Integer> myList = new ArrayList<Integer>();

                for (int i = this.a; i < this.b; i++) {
                    myList.add(i);
                }
                return myList;
            }

            public boolean isPrime(int num)
            {
                boolean isPrime = false;
                for (int i = 2; i <= num / 2; ++i) {
                    if (num % i == 0) {
                        isPrime = true;
                        break;
                    }
                }

                return isPrime;
            }

            @Override
            public List<Integer> getAllDivisors() {
                List<Integer> myList = new ArrayList<Integer>();

                for (int i = 1; i < this.a; i++) {
                    if (this.a % i == 0) {
                        myList.add(i);
                    }
                }

                return myList;
            }

            @Override
            public List<Integer> getAllEasyDivisors() {
                List<Integer> myList = this.getAllDivisors();
                List<Integer> primeDivisors = new ArrayList<Integer>();

                for (int item : myList) {
                    if (this.isPrime(item)) {
                        primeDivisors.add(item);
                    }
                }

                return primeDivisors;
            }

            @Override
            public int[] getMostFrequentNumbers() {
                return new int[0];
            }
        }
    }
}