Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

HCF of list of number

// call this function
    public static int gcd(List<int> input) 
    {
        int result = input[0];
        for (int i = 1; i < input.Count; i++) 
        {
            result = gcd(result, input[i]);
        }
        return result;
    }
    
    private static int gcd(int a, int b) 
    {
        while (b > 0) 
        {
            int temp = b;
            b = a % b; // % is remainder
            a = temp;
        }
        return a;
    }
Comment

PREVIOUS NEXT
Code Example
Csharp :: timespan to integer c# 
Csharp :: c# open file for reading and writing 
Csharp :: c# isdigit mehod 
Csharp :: c# readline char 
Csharp :: array of strings by splitting lines c# 
Csharp :: how to make a character run in unity 
Csharp :: C# using variables inside strings 
Csharp :: getter setter c# 
Csharp :: how to get total scenes unity 
Csharp :: update listbox using class c# 
Csharp :: convert list of tuples to dictionary c# 
Csharp :: ternary operator c# 
Csharp :: how to print statement in c# 
Csharp :: c# remove item from list 
Csharp :: limiting the amount of decimal places c# 
Csharp :: unity c# change animation 
Csharp :: how to find the tag of an objecdt in unity 
Csharp :: c# convert enumb to int array 
Csharp :: how to destroy parent gameobject unity 
Csharp :: pyautogui not odwnloading 
Csharp :: remove force unity 
Csharp :: c# string console readline array 
Csharp :: how to find the multiples of 3 c# 
Csharp :: unity c# cos inverse 
Csharp :: group by unique c# 
Csharp :: c# form set auto scale 
Csharp :: c# best way to loop and remove 
Csharp :: ihttpactionresult to object c# 
Csharp :: declare enum c# 
Csharp :: string in c# 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =