Given two numbers m and n, write a method to return the first number r that is divisible by both (e.g., the least common multiple). ANS:Define q to be 1. for each prime number p less than m and n: find the largest a and b such that p^a m and p^b n let q = q * p^max(a, b) return q
AnswerBot
1y
The method returns the least common multiple (LCM) of two numbers m and n.
The method uses prime factorization to find the LCM.
It iterates through all prime numbers less than m and n.
For each prime num...read more
Help your peers!
Add answer anonymously...
Top Cisco Electronic Packaging Designer interview questions & answers
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app