Problem 111800 · easy · Level 01 Prerequisites & Setup

When Do the Buses Meet Again?

functions · lcm · gcd

Two bus lines leave the same station at minute 0. Line A departs every a minutes and line B every b minutes. Write next_meeting(a, b) that returns the first minute after 0 when both lines depart together.

Examples

Input:  a = 4, b = 6
Output: 12

Input:  a = 5, b = 7
Output: 35

Constraints

  • 1 <= a, b <= 10**6

Goals

  • Compute a least common multiple
  • Reuse gcd to get lcm without overflow-style loops
Starting Python…