Four Integers

 Coding Problem Keys 

 Four Integers 

 Problem Statement 

Four integers are passed as the input to the program. Among them one of the integers X is a factor of another two numbers but not a factor of the third number. Finally the program must print the value of X.

 Boundary Condition(s) 

2 <= Each integer value <= 1000

 Input Format 

The first line contains four integers separated by a space.

 Output Format 

The first line contains X.

 Example Input/Output 1 

 Input 

10 30 6 42

 Output 

6

 Explanation 

6 is a factor of 30 and 42 but it is not a factor of 10.

 Example Input/Output 2 

 Input 

25 75 5 100

 Output 

25

 Explanation 

25 is a factor of 75 and 100 but it is not a factor of 5.

 Note: Max Execution Time Limit: 500 millisecs 

 Solution 

 Programming Language: Python 3 Language 

a,b,c,d=sorted(map(int,input().split()))
if c%b or d%b:
    print(a)
else:
    print(b)

# Published By PKJCODERS

 (Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.) 

Comments

Popular Posts

Highly Profitable Months

Flowchart Logic 047

Desktop Products

Find Maxima/Minima

Matrix Print Excluding Border Elements

Words Starting with Upper Case

Occurrences of Sub in Parent