Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,900 questions

51,831 answers

573 users

How to find the biggest dividers of two numbers in C#

1 Answer

0 votes
using System;

public class BiggestDividersOfTwoNumber
{
    public static void Main(string[] args)
    {
        int a = 60, b = 72, BiggestDivider = 0;
 
        for (int i = 1; i <= a / 2; i++) {
            if (a % i == 0 && b % i == 0) {
                Console.Write("{0, 3}", i);
                BiggestDivider = i;
            }
        }
        Console.WriteLine("\nThe biggest dividers of two number is: {0}", BiggestDivider);
    }
}



/*
run:

  1  2  3  4  6 12
The biggest dividers of two number is: 12

*/


answered Apr 10, 2014 by avibootz
edited Jan 18, 2025 by avibootz

Related questions

1 answer 72 views
1 answer 257 views
1 answer 162 views
162 views asked Apr 10, 2014 by avibootz
1 answer 153 views
3 answers 224 views
...