Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

lcm recursive program in c++

int lcm(int a, int b)
{
  // static variable
  static int common = 0;

  // add largest number
  common += b; 

  // base case
  if(common%a == 0) return common; 

  // general case
  else return lcm(a, b); 
}
Source by www.knowprogram.com #
 
PREVIOUS NEXT
Tagged: #lcm #recursive #program
ADD COMMENT
Topic
Name
7+9 =