Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
LCM and GCD
//Catheti: 3 and 4 //Catheti: 10 and 12 //Catheti 100 and 250 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static int GCD (int a, int b) { int n = Math.Min (a, b); int gcd = 1, i = 1; while (i <= n) { if (a % i == 0 && b % i == 0) { gcd = i; } i++; } return gcd; } public static void Main(string[] args) { //Your code goes here //lcm(a, b) = a × b / gcd(a, b) int number1 = 1234; int number2 = 3456; int gcd = 1; double lcm = 0; gcd = GCD(number1, number2); Console.WriteLine(gcd); lcm = ((number1 * number2) / gcd); Console.WriteLine(lcm); } } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Šovljanski - beskonačna petlja bez goto-a
Puzz1
linq
Problem: fb_series
mysrc.tcl
Lesson 2-2
multi variable random number generator
IEquatable doubt resolved!!
Fórum ➡ Finding STRONG tags that contain UL tags, using Regex class♦
Codenew
stackse - search stackoverflow differently
Please log in to post a comment.