@@ -0,0 +1,938 @@
+package com.interview.misc;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * All prime numbers before n%0A */%0Apublic class PrimeNumbersBeforeN %7B%0A%0A    public List%3CInteger%3E primeNumbers(int n)%7B%0A        List%3CInteger%3E result = new ArrayList%3CInteger%3E();%0A        result.add(2);%0A        boolean flag = false;%0A        for(int i=3; i %3C n; i+=2)%7B%0A            for(int r : result)%7B%0A                if(2*r %3E i)%7B%0A                    break;%0A                %7D%0A                if(i %25 r == 0)%7B%0A                    flag = true;%0A                    break;%0A                %7D%0A            %7D%0A            if(!flag)%7B%0A                result.add(i);%0A            %7D%0A            flag = false;%0A        %7D%0A        return result;%0A    %7D%0A    %0A    public static void main(String args%5B%5D)%7B%0A        PrimeNumbersBeforeN pnb = new PrimeNumbersBeforeN();%0A        List%3CInteger%3E result = pnb.primeNumbers(150);%0A        result.forEach(i -%3E System.out.print(i + %22 %22));%0A    %7D%0A%7D%0A

Prime numbers before n