Answers for "Project Euler #5"

0

Project Euler #5

public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        for(int a0 = 0; a0 < t; a0++){
            int n = in.nextInt();
        int a = 1;
        int r = 0;

        for (int b = 1; b <= n; b++) {
            r = a * b;
            for (int i = b; i > 1; i--) {
                if (a % i == 0 && b % i == 0) {
                    r = r / i;
                    break;
                }

            }
         
            a = r;
        }
        System.out.println(r);
        
        }
    }
Posted by: Guest on June-12-2021

Code answers related to "Project Euler #5"

Browse Popular Code Answers by Language