# Can someone walk me through a solution to Smallest Common Multiple

Tell us what’s happening:
I solved this challenge with a while loop, but I was looking for something simpler and a friend sent me a link for a recursive approach on GitHub. I don’t quite understand how it does any of the things required to find SCM and I think it is just looking for GCD. But perhaps I am misunderstanding the code. I’ll post it below. If it is just to find GCD, then I just need to apply a little extra code to determine SCM. But…I don’t quite understand it, so…

Anyway, I’ll post what I think I understand of it below and please correct my logic where necessary…

``` Recursive version of Euclidean Algorithm of finding greatest common divisor (GCD). @param {number} originalA @param {number} originalB @return {number} */ export default function euclideanAlgorithm(originalA, originalB) { // Make input numbers positive. const a = Math.abs(originalA); const b = Math.abs(originalB); // To make algorithm work faster instead of subtracting one number from the other // we may use modulo operation. return (b === 0) ? a : euclideanAlgorithm(b, a % b); } ```

So, as I understand it, the assignment of const variables to different perimeters of the function since you need the variables to remain the same in order to iterate through an array without heading into anything messy like Infinity.
The return statement I can read but I don’t understand how it really accomplishes anything…

``````

User Agent is: <code>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36</code>.

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/smallest-common-multiple``````

Looks like this just finds the GCD.

It would be the same as writing.

``````function gcd(a,b) {
if (b === 0) {
return a;
} else {
return gcd(b, a % b);
}
}
``````