Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SoftUniiii
- {
- class Program
- {
- static void swap(ref int num1, ref int num2)
- {
- int temp = num1;
- num1 = num2;
- num2 = temp;
- }
- static int GCD(int a, int b)
- {
- for (int i = Math.Min(a, b); i >= 1; i--)
- {
- if (a % i == 0 && b % i == 0)
- {
- return i;
- }
- }
- return 1;
- }
- static int Euclid1GCD(int a, int b)
- {
- while (a != b)
- {
- if (a > b)
- {
- a -= b;
- }
- else
- {
- b -= a;
- }
- }
- return a;
- }
- static int Euclid2GCD(int a, int b)
- {
- while (a != b)
- {
- if (a < b)
- {
- swap(ref a, ref b);
- }
- a -= b;
- }
- return a;
- }
- static int Euclid3GCD(int a, int b)
- {
- while (b != 0)
- {
- a %= b;
- swap(ref a, ref b);
- }
- return a;
- }
- static double CircleArea(double radius)
- {
- double area = Math.PI * Math.Pow(radius, 2);
- return area;
- }
- static int LCM(int a, int b)
- {
- for (int i = Math.Max(a, b); i <= a * b; i++)
- {
- if (i % a == 0 && i % b == 0)
- {
- return i;
- }
- }
- return a * b;
- }
- static void Main(string[] args)
- {
- int a = 20, b = 10, c = 15;
- int g = GCD(GCD(a, b), c);
- Console.WriteLine(g);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement