# How to find LCM

**URL:** <https://community.thunkable.com/t/how-to-find-lcm/1265548>\
**Category:** Questions about Thunkable X\
**Tags:** beginner\
**Created:** [May 6, 2021, 12:48am UTC](https://community.thunkable.com/t/how-to-find-lcm/1265548 "2021-05-06T00:48:30Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![adityaparsad01665xhi](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@adityaparsad01665xhi](https://community.thunkable.com/u/adityaparsad01665xhi)\
**Post date:** [May 6, 2021, 12:48am UTC](https://community.thunkable.com/t/how-to-find-lcm/1265548/1 "2021-05-06T00:48:31Z")

</div>

Dear Team,

I want to find LCM, I try but got error.please help

 ![blocks(1)](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/5/f57477904f2547039348768d36d6e64210694239.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [May 6, 2021, 2:00am UTC](https://community.thunkable.com/t/how-to-find-lcm/1265548/2 "2021-05-06T02:00:23Z")

</div>

What is the source of your algorithm?

---

<div class="post-metadata">

**Author:** ![adityaparsad01665xhi](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@adityaparsad01665xhi](https://community.thunkable.com/u/adityaparsad01665xhi)\
**Post date:** [May 6, 2021, 2:08am UTC](https://community.thunkable.com/t/how-to-find-lcm/1265548/3 "2021-05-06T02:08:44Z")

</div>

Github

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [May 6, 2021, 2:27am UTC](https://community.thunkable.com/t/how-to-find-lcm/1265548/4 "2021-05-06T02:27:59Z")

</div>

> [@adityaparsad01665xhi](#):
>
> Github

That’s kind of like if I told you I was building a bicycle and you asked where the instructions were and I said “on paper.”

I was hoping to see the algorithm so I could help you figure out why your blocks aren’t following it correctly.

**Edit:** ah, there they are below.

---

<div class="post-metadata">

**Author:** ![adityaparsad01665xhi](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@adityaparsad01665xhi](https://community.thunkable.com/u/adityaparsad01665xhi)\
**Post date:** [May 6, 2021, 2:32am UTC](https://community.thunkable.com/t/how-to-find-lcm/1265548/5 "2021-05-06T02:32:28Z")

</div>

/\*  
author: PatOnTheBack  
license: GPL-3.0 or later

```
Modified from:
    https://github.com/TheAlgorithms/Python/blob/master/maths/findLcm.py

More about LCM:
    https://en.wikipedia.org/wiki/Least_common_multiple

```

\*/

‘use strict’

// Find the LCM of two numbers.  
const findLcm = (num1, num2) =\> {  
// If the input numbers are less than 1 return an error message.  
if (num1 \< 1 || num2 \< 1) {  
return ‘Please enter values greater than zero.’  
}

// If the input numbers are not integers return an error message.  
if (num1 !== Math.round(num1) || num2 !== Math.round(num2)) {  
return ‘Please enter whole numbers.’  
}

let maxNum  
let lcm  
// Check to see whether num1 or num2 is larger.  
if (num1 \> num2) {  
maxNum = num1  
} else {  
maxNum = num2  
}  
lcm = maxNum

while (true) {  
if (lcm % num1 === 0 && lcm % num2 === 0) break  
lcm += maxNum  
}  
return lcm  
}

export { findLcm }

Convert this onto block

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [May 6, 2021, 2:36am UTC](https://community.thunkable.com/t/how-to-find-lcm/1265548/6 "2021-05-06T02:36:03Z")

</div>

What are you using to code this? It’s not Thunkable X.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [May 6, 2021, 2:41am UTC](https://community.thunkable.com/t/how-to-find-lcm/1265548/8 "2021-05-06T02:41:21Z")

</div>

> [@adityaparsad01665xhi](#):
>
> if (num1 \> num2) {  
> maxNum = num1  
> } else {  
> maxNum = num2  
> }  
> **lcm = maxNum**

You missed a line (in bold).

---

<div class="post-metadata">

**Author:** ![adityaparsad01665xhi](https://avatars.discourse-cdn.com/v4/letter/a/90ced4/32.png) [@adityaparsad01665xhi](https://community.thunkable.com/u/adityaparsad01665xhi)\
**Post date:** [May 6, 2021, 2:49am UTC](https://community.thunkable.com/t/how-to-find-lcm/1265548/9 "2021-05-06T02:49:03Z")

</div>

Try to run this code.

---

<div class="post-metadata">

**Author:** ![luv.ak.tech](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/luv.ak.tech/32/104896_2.png) [@luv.ak.tech](https://community.thunkable.com/u/luv.ak.tech)\
**Post date:** [May 6, 2021, 3:09am UTC](https://community.thunkable.com/t/how-to-find-lcm/1265548/10 "2021-05-06T03:09:07Z")

</div>

> [@adityaparsad01665xhi](#):
>
> Dear Team,
> 
> I want to find LCM, I try but got error.please help
> 
> ![blocks(1)](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/5/f57477904f2547039348768d36d6e64210694239.png)

this is kodular and you asked the same thing here -

> **[How do I calculate LCM?](https://community.appinventor.mit.edu/t/how-do-i-calculate-lcm/32575)**
>
> Dear Team, I want to find LCM, I try but got error.please help

> **[How to Find LCM?](https://community.kodular.io/t/how-to-find-lcm/119901)**
>
> Dear Team, I want to find LCM, I try but got error.please help

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [May 6, 2021, 4:21am UTC](https://community.thunkable.com/t/how-to-find-lcm/1265548/11 "2021-05-06T04:21:05Z")

</div>

I’m going to close this topic since you’re not using Thunkable. Hopefully someone on those other forums can help you.

I see you’ve also been warned by other forum moderators on those sites.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [May 6, 2021, 4:21am UTC](https://community.thunkable.com/t/how-to-find-lcm/1265548/12 "2021-05-06T04:21:09Z")

</div>


