Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
谁能帮帮我,我不知道如何找到最小的公倍数。
例如,数字 4 和 5 是 20。这就是我想要在代码中实现的目标。
谢谢
这不是最好的解决方案,但它是一个解决方案,请参阅回复中的链接以获得更好的解决方案
b = 4; a = 5; for(int i = 1; i <= b; i++) { if(i*a % b == 0) return abs(i*a); }
感谢 iamnotmaynard 的建议