3
Contributors
2
Replies
4
Views
9 Years
Discussion Span
Last Post by puneetkay
0

I give algorithm you try it in C#

HCF (GCD) Algorithm

GCD ( M, N ) {
If N > M then return GCD ( N, M )
else If N = 0 then return M
else return GCD ( N, MOD ( M, N) )
}

It is simple to covert it to C#
Also it is for two input

For three input

GCD ( M, N, O ){
return GCD ( M, GCD ( N, O ) )
}

0

I give algorithm you try it in C#

HCF (GCD) Algorithm

GCD ( M, N ) {
If N > M then return GCD ( N, M )
else If N = 0 then return M
else return GCD ( N, MOD ( M, N) )
}

It is simple to covert it to C#
Also it is for two input

For three input

GCD ( M, N, O ){
return GCD ( M, GCD ( N, O ) )
}

Hie,

Thanks buddy, but i didnt really get the algo.
Heres the one from me:
=======
1 Input: num type variables M,N, HCF. (eg: M=100, N=125)
2 Find the smaller one from M,n. (eg: smaller: M)
3 Start a loop from M to M/2. (eg: i=m;i<=m/2;i++)
___1 Check whether i%m=0 & i%n==0.
___2 HCF = i; break;

Hope this can help you! :)

Regards,
PuneetKay

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.