We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ac9ff76 commit cf5c2baCopy full SHA for cf5c2ba
src/runtime/math.py
@@ -109,3 +109,30 @@ def pow(x: f64, y: f64) -> f64:
109
Return `x` raised to the power `y`.
110
"""
111
return x**y
112
+
113
114
+def mod(a: i32, b: i32) -> i32:
115
+ """
116
+ Returns a%b
117
118
+ return a - (a//b)*b
119
120
121
+def gcd(a: i32, b: i32) -> i32:
122
123
+ Returns greatest common divisor of `a` and `b`
124
125
+ temp: i32
126
+ while b != 0:
127
+ a = mod(a, b)
128
+ temp = a
129
+ a = b
130
+ b = temp
131
+ return a
132
133
134
+def lcm(a: i32, b: i32) -> i32:
135
136
+ Returns least common multiple of `a` and `b`
137
138
+ return (a*b)//gcd(a, b)
0 commit comments