This commit is contained in:
Rohit Tanwar
2018-01-09 10:22:55 +05:30
parent a09142e1eb
commit 67a6482d95
4 changed files with 11 additions and 7 deletions

View File

@ -1,10 +1,10 @@
### gcd
Calculates the greatest common divisor between two or more numbers/arrays.
Calculates the greatest common divisor between two or more numbers/lists.
The `helperGcdfunction` uses recursion. Base case is when `y` equals `0`. In this case, return `x`. Otherwise, return the GCD of `y` and the remainder of the division `x/y`.
Uses the reduce function from the inbuild module `functools`. Also defines a method `spread` for javascript like spreading of arrays.
Uses the reduce function from the inbuilt module `functools`. Also defines a method `spread` for javascript like spreading of lists.
```python
from functools import reduce