search
HomeCommon Problemleast common multiple algorithm

least common multiple algorithm

Jun 10, 2019 pm 01:48 PM

least common multiple algorithm

1. Method of decomposing prime factors

First write out the prime factors of these numbers. The least common multiple is equal to all their prime factors. The product of (if several prime factors are the same, compare which of the two numbers has more prime factors and multiply them more times).

For example, find the least common multiple of 45 and 30.

45=3*3*5

30=2*3*5

The different prime factors are 2, 5, and 3, which are the prime factors of both of them. Factor, since 45 has two 3s and 30 has only one 3, so when calculating the least common multiple, multiply by two 3s.

2. Formula method

Since there are two The product of numbers is equal to the product of the greatest common divisor and the least common multiple of the two numbers. That is (a, b) × [a, b] = a × b. Therefore, to find the least common multiple of two numbers, you can first find their greatest common divisor, and then use the above formula to find their least common multiple.

For example, if you find [18, 20], you get [18, 20] = 18 × 20 ÷ (18, 20) = 18 × 20 ÷ 2 = 180. To find the least common multiple of several natural numbers, you can first find the least common multiple of two of the numbers, then find the least common multiple of this least common multiple and the third number, and continue to find the last one. The least common multiple obtained in the end is the least common multiple of the numbers sought.

The above is the detailed content of least common multiple algorithm. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:baidu. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use