GCD Of Two Numbers

GCD Of Two Numbers

Easy Computer Mathematics GCD/LCM & Euclid 26 views
Explanation Complexity

Problem Statement

Compute gcd(a,b).

Input Format

Two integers a b.

Output Format

One integer gcd.

Example

18 48
6

Constraints

|a|,|b|

Input / Output Format

Input Format
Two integers a b.
Output Format
One integer gcd.
Constraints
|a|,|b|

Examples

Input:
18 48
Output:
6

Example Solution (Public)

Computer Mathematics
Use Euclid: while b!=0 set (a,b)=(b,a%b). Answer is abs(a).

Official Solution Code

Use Euclid: while b!=0 set (a,b)=(b,a%b). Answer is abs(a).
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.