Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

hcf of numbers

// 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

hcf of numbers


def hcf(num1,num2):
    if num2==0:
        return num1
    else:
        return hcf(num2, num1%num2)

res = hcf(num1, num2)    
print('The highest common factor is', res)

Comment

PREVIOUS NEXT
Code Example
Csharp :: c# radio button checked 
Csharp :: qtablewidget add image 
Csharp :: json property c# 
Csharp :: how use vue createApp 
Csharp :: or in if statement c# 
Csharp :: c# get excel column number from letter 
Csharp :: nunjucks index in loop 
Csharp :: sqldatareader in c# 
Csharp :: make command prompt hidden c# 
Csharp :: constructor c# 
Csharp :: c# binding add combobox with enum values 
Csharp :: ternary operator in c# 
Csharp :: unity send post request json 
Csharp :: c# new list of objects 
Csharp :: c# signalr console app client example 
Csharp :: if checkbox checked in c# 
Csharp :: c# how to set string list 
Csharp :: c# verify in class exist in list 
Csharp :: c# get gridview DataKeyNames 
Csharp :: pyautopgui wrros on big sur 
Csharp :: C# bitwise operation 
Csharp :: published net core did not have wwwroot 
Csharp :: change sprite color unity 
Csharp :: unity render to texture2d 
Csharp :: unity2d movement 
Csharp :: c# ternary operator 
Csharp :: c# chunk array linq 
Csharp :: ? operator 
Csharp :: asp net img src path from database 
Csharp :: string c# 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =