Skip to content

The Greatest Common Divisor (GCD) of two integers is the largest positive integer that divides both numbers without leaving a remainder.The Least Common Multiple (LCM) of two integers is the smallest positive integer that is a multiple of both numbers.

Notifications You must be signed in to change notification settings

Soren2007/algorithm-GCD-and-LCM-590

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

GCD and LCM

  • Time Limit: 1 second
  • Memory Limit: 256 MB

Write a program that receives two numbers m and n and prints their GCD and LCM.

Input

First, you are given n and then m.

1 <= n, m <= 10^9

Output

Print the GCD first, followed by the LCM, separated by a space.

Example

Sample Input

8 20

Sample Output

4 40

ب.م.م و ک.م.م

  • محدودیت زمان: 1 ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

برنامه‌ای بنویسید که دو عدد m و n را دریافت کرده و ب.م.م و ک.م.م آن‌ها را چاپ کند.

ورودی

در یک ابتدا n و سپس m به شما داده می‌شود.

1 <= n, m <= 10^9

خروجی

ابتدا ب.م.م. و سپس ک.م.م. را جدا شده با فاصله چاپ کنید.

مثال

ورودی نمونه

8 20

خروجی نمونه

4 40

About

The Greatest Common Divisor (GCD) of two integers is the largest positive integer that divides both numbers without leaving a remainder.The Least Common Multiple (LCM) of two integers is the smallest positive integer that is a multiple of both numbers.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages