Trending This Week:

test

Post Top Ad

Monday, June 13, 2022

C++ program to find LCM.

  





What is LCM?

For a given set of numbers, the LCM is the smallest number that is a multiple of every one of the numbers




C++ program to find LCM.


cpp
#include <iostream> using namespace std; int main() {   int a,b,r,lcm; cout<<"Enter Two Numbers(First Number Should be big) : "; cin>>a>>b; while(1) { lcm=r; r=a%b; if(r==0) break; else a*=2; } cout<<"LCM Is : "<<a; return 0; }

Output :










No comments:

Post a Comment

Post Top Ad