Sunday, 21 December 2014

GCD of Two Number in Wipro Format

int g=0,i=0;
g = gcd(input2[0], input2[1]);
if(input1 > 2){
for(i=2; i < input1; i++)
{
g = gcd(g, input2[i]);
}
}
Output1=g;
}
public static int gcd(int a, int b)
{
 if (b == 0)
 {
  return a;
 } else
 {
  return gcd(b, a % b);
  }  
int g=0,i=0;
g = gcd(input2[0], input2[1]);
if(input1 > 2){
for(i=2; i < input1; i++)
{
g = gcd(g, input2[i]);
}
}
Output1=g;
}
public static int gcd(int a, int b)
{
 if (b == 0)
 {
  return a;
 } else
 {
  return gcd(b, a % b);
  }    

3 comments:

  1. good work...keep going on

    ReplyDelete
  2. what about c++ programs ?

    ReplyDelete
  3. blog bana ke bhul gae kya ki age bhi post karne hote h or comments ke jawab dene hote h. C++ ke programs ke lie sab itne din se request kr re h par aap log to pata nhi kon si dunia me mast ho

    ReplyDelete