Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

gcd 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 :: c# read csv file 
Csharp :: unity 3d movement script 
Csharp :: how to disable vsync in monogame 
Csharp :: c# foreach object in array json 
Csharp :: how to deactivate an object unity 
Csharp :: how to flip a character in unity 2d 
Csharp :: c# .net core memory cache 
Csharp :: mfind how many digits a number has c# 
Csharp :: c# list of properties from list of objects 
Csharp :: c# empty array 
Csharp :: c# file read 
Csharp :: c# datetime for filename 
Csharp :: asp.net mvc get current url in view 
Csharp :: increase value in dictionary against a key in c# 
Csharp :: c# get list item in random order 
Csharp :: c# regex replace all line breaks 
Csharp :: null check syntax c# 
Csharp :: make variables in c# 
Csharp :: C# clear form 
Csharp :: c# loops 
Csharp :: unity rigid body variable 
Csharp :: c# itext 7 PdfDocument from byte array 
Csharp :: c# max two values 
Csharp :: stringify c# 
Csharp :: c# read double 
Csharp :: how set cascade on delete and update in same time in laravel 
Csharp :: C# Bitwise Right Shift 
Csharp :: c# convert double to string 
Csharp :: c# loop through datatable and update 
Csharp :: color32 unity 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =