Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
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
any predicate test
3. Delegates and events
Plt-D v.0.8.4
pattern2
IEnumeratorExample
AnonymousFunction (demo)
GEFCSADX
Mintra url string replace
Generic operator test
D18