File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import java .util .*;
2+
3+ public class Main {
4+ static int [] arr = new int [5 ];
5+
6+ static int min = Integer .MAX_VALUE ;
7+
8+ public static void main (String [] args ) {
9+
10+ Scanner sc = new Scanner (System .in );
11+
12+ for (int i = 0 ; i < 5 ; i ++) {
13+ arr [i ] = sc .nextInt ();
14+ }
15+
16+ solve ();
17+
18+ }
19+
20+ public static void solve () {
21+
22+ for (int i = 0 ; i < 5 ; i ++) {
23+ for (int j = i + 1 ; j < 5 ; j ++) {
24+ for (int k = j + 1 ; k < 5 ; k ++) {
25+ int lcm = lcm (arr [i ], arr [j ], arr [k ]);
26+ min = Math .min (min , lcm );
27+ }
28+ }
29+ }
30+
31+ System .out .println (min );
32+ }
33+
34+ public static int gcd (int a , int b ) {
35+ while (b != 0 ) {
36+ int temp = b ;
37+ b = a % b ;
38+ a = temp ;
39+ }
40+ return a ;
41+ }
42+
43+ public static int lcm (int a , int b ) {
44+ return (a * b ) / gcd (a , b );
45+ }
46+
47+ public static int lcm (int a , int b , int c ) {
48+ return lcm (lcm (a , b ), c );
49+ }
50+
51+ }
You can’t perform that action at this time.
0 commit comments