Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Need some help making this easier to use.
- bool NextP = true; //outer loop
- int Up = 1, N1 = 2, N2 = 1;
- unsigned long int Mul = 0, Dev = 0;
- int Fixer = 0;
- //LCM - Least Common Multiple
- while(NextP)
- {
- Up = 1;
- N1 = 0;
- N2 = 0;
- if(NextP)
- {
- printf("Enter both numbers below.... \n");
- printf("The first number must be larger than the second number\n");
- printf("Enter 0 for both numbers to exit. \n");
- cin >> N1 >> N2;
- cout << endl;
- }
- else
- {
- printf("Exiting Program! \n");
- }
- if(N1 != 0 && N2 != 0)
- {
- //LCM loops start
- if( (N1 > N2) )
- {
- do
- {
- Mul = N2 * Up;
- //cout << N1 << " * " << Up << " = " << Mul <<endl;
- Dev = Mul / N1;
- //printf(" %f / %f = %f \n",Mul,N2,Dev);
- printf("Loop %d \n",(int)Up);
- Up++;
- }
- while(!IsWholeNumberFloat(Mul, N1));
- Fixer = (int)Up - 1;
- printf("Whole Number After %d Loops\n\n", Fixer);
- if(IsWholeNumber(Mul, Fixer))
- {
- //printf("These are the hole numbers");
- cout << N2 << " * " << Up - 1 << " = " << Mul <<endl;
- cout << Mul << " / " << N1 << " = " << Dev << endl;
- }
- }
- else if((N2 > N1))
- {
- do
- {
- Mul = N1 * Up;
- //cout << N1 << " * " << Up << " = " << Mul <<endl;
- Dev = Mul / N2;
- //printf(" %f / %f = %f \n",Mul,N2,Dev);
- printf("Loop %d \n",(int)Up);
- Up++;
- }
- while(!IsWholeNumberFloat(Mul, N2));
- Fixer = (int)Up - 1;
- printf("Whole Number After %d Loops\n\n", Fixer);
- if(IsWholeNumber(Mul, Fixer))
- {
- //printf("These are the hole numbers");
- cout << N1 << " * " << Up - 1 << " = " << Mul <<endl;
- cout << Mul << " / " << N2 << " = " << Dev << endl;
- }
- }
- else
- {
- system("cls");
- cout << "Programming or Input Error of some kind!?!?!?" << endl;
- cout << "OR" << endl;
- cout << "I just didn't want to show the math for two of the same number!" << endl;
- cout << "OR" << endl;
- cout << "You needed a clearing of the screen?" << endl;
- cout << endl;
- }
- //LCM loops end
- }
- else if(N1 == 0 && N2 == 0)
- {
- NextP = false;
- printf("Exiting Program! \n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement