Want to Calculate Least common multiple (LCM) and Greatest common divisor (GCD)

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
All the math needed to calculate the GCD and LCM can be done in events. Do you need a plugin specifically?
 

gece

Villager
Member
Joined
Oct 5, 2016
Messages
9
Reaction score
1
Primarily Uses
N/A
All the math needed to calculate the GCD and LCM can be done in events. Do you need a plugin specifically?
Not really need plugin. i checked wikipedia pages for GCD and LCM formulas, but it is too much complicated to do it with events for me. should i focus on eventing? i dont prefer somebody to make my own work but be pleased if you help about it.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
You can make it in the script command of events, if using the math event commands would too troublesome
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
Taking the formula from the link you first gave for the Greatest Common Divisor
Code:
while(y) {
    var t = y;
    y = x % y;
    x = t;
}
return x;
Each line in that formula is almost one-for-one with event commands. If you know how to use "Control Variables" event command, then you should be able to understand what these event commands are doing. I put a comment of the formula that you provided before it's corresponding event command.

◆Text:None, Window, Bottom
: :Input the first number:
◆Input Number:Number1 (x), 3 digits
◆Text:None, Window, Bottom
: :Input the second number:
◆Input Number:Number2 (y), 3 digits
◆Comment:while(y)
◆Loop
◆If:Number2 (y) = 0
◆Break Loop

:End
◆Comment:var t = y;
◆Control Variables:#0011 temp (t) = Number2 (y)
◆Comment:y = x % y
◆Control Variables:#0010 Number2 (y) = Number1 (x)
◆Control Variables:#0010 Number2 (y) %= temp (t)
◆Comment:x = t;
◆Control Variables:#0009 Number1 (x) = temp (t)

:Repeat Above
◆Comment:return x;
◆Text:None, Window, Bottom
: :The Greatest Common Divisor is \v[9]

upload_2019-7-26_19-50-3.png
 

gece

Villager
Member
Joined
Oct 5, 2016
Messages
9
Reaction score
1
Primarily Uses
N/A
I meneged to make this with eventing, thanks for your attention and help. i ll give you a credit in my project Aloe Guvner :rock-left:
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
Sounds good, no need to credit me. Hopefully you can apply the same concepts to the Lowest Common Multiple
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,047
Messages
1,018,540
Members
137,834
Latest member
EverNoir
Top