MCPcopy Create free account
hub / github.com/Ainevsia/Leetcode-Rust / gcd

Method gcd

149. Max Points on a Line/Solution.cpp:17–30  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15class Solution {
16public:
17 int gcd(int a, int b) {
18 if ( a < b ) {
19 // make a the larger one
20 int tmp = b;
21 b = a;
22 a = tmp;
23 }
24 while (b != 0) {
25 int remaind = a % b;
26 a = b;
27 b = remaind;
28 }
29 return a;
30 }
31
32 /// how to use 2 integers to represent a double
33 /// if 0 -> up = 0, do not represent inf

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected