User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 425,895 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,926 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser: Programming Forums
Views: 366 | Replies: 2
Reply
Join Date: Feb 2008
Posts: 17
Reputation: arupa is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
arupa arupa is offline Offline
Newbie Poster

HCF

  #1  
Jul 9th, 2008
write a program to calculate the Highest Common Factor of three input numbers
Arupananda Behera
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2008
Location: Sivakasi, Tamilnadu, India
Posts: 458
Reputation: selvaganapathy is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 79
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro in Training

Re: HCF

  #2  
Jul 9th, 2008
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 ) )
}
KSG
Reply With Quote  
Join Date: Nov 2007
Posts: 28
Reputation: puneetkay is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 6
puneetkay's Avatar
puneetkay puneetkay is offline Offline
Light Poster

Re: HCF

  #3  
Jul 11th, 2008
Originally Posted by selvaganapathy View Post
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
Last edited by puneetkay : Jul 11th, 2008 at 10:26 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C# Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C# Forum

All times are GMT -4. The time now is 7:22 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC