<br />
<b>Warning</b>:  Undefined array key "global_protection_id" in <b>/home/wikitechy/public_html/interview-questions/wp-content/plugins/content-protector/inc/class-ps-rest-handler.php</b> on line <b>51</b><br />
{"id":339,"date":"2021-07-12T21:04:03","date_gmt":"2021-07-12T21:04:03","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=339"},"modified":"2021-09-14T05:52:29","modified_gmt":"2021-09-14T05:52:29","slug":"how-to-find-lcm-of-two-numbers-in-c","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/c\/how-to-find-lcm-of-two-numbers-in-c\/","title":{"rendered":"How to find LCM of two Numbers in C ?"},"content":{"rendered":"<h2 id=\"to-find-lcm-of-two-numbers-in-c\" class=\"color-pink\" style=\"text-align: justify;\">To Find LCM of Two Numbers in C<\/h2>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li>The LCM of two numbers a and b is the smallest positive integer that is perfectly divisible by both a and b (without a remainder). For example: The LCM of 72 and 120 is 360.<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<div class=\"text-center row\" style=\"text-align: justify;\"><\/div>\n<h2 id=\"sample-code\" class=\"color-blue\" style=\"text-align: justify;\">Sample Code<\/h2>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-c code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-c code-embed-code\">#include &lt;stdio.h&gt; <br\/>\/\/ Recursive function to return gcd of a and b<br\/>int gcd(int a, int b)<br\/>{<br\/>\/\/ Everything divides 0<br\/>    if (a == 0 || b == 0)<br\/>        return 0;<br\/>\/\/ Base case<br\/>    if (a == b)<br\/>        return a;<br\/>\/\/ a is greater<br\/>    if (a &gt; b)<br\/>        return gcd(a-b, b);<br\/>    return gcd(a, b-a);<br\/>}<br\/>\/\/ Function to return LCM of two numbers<br\/>int lcm(int a, int b)<br\/>{<br\/>    return (a*b)\/gcd(a, b);<br\/>}<br\/>\/\/ Driver program to test above function<br\/>int main()<br\/>{<br\/>    int a = 10, b = 28;<br\/>    printf(&quot;LCM of %d and %d is %d &quot;, a, b, lcm(a, b));<br\/>    return 0;<br\/>}<\/code><\/pre> <\/div>\n<h2 id=\"output\" class=\"color-blue\" style=\"text-align: justify;\">Output<\/h2>\n<div class=\"Output\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<figure class=\"highlight\"><div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-c code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-c code-embed-code\">LCM of 10 and 28 is 140<\/code><\/pre> <\/div><\/figure>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Answer : The LCM of two numbers a and b is the smallest positive integer that is perfectly divisible&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"passster_activate_protection":false,"passster_protect_child_pages":"","passster_protection_type":"password","passster_password":"","passster_activate_overwrite_defaults":"","passster_headline":"","passster_instruction":"","passster_placeholder":"","passster_button":"","passster_id":"","passster_activate_misc_settings":"","passster_redirect_url":"","passster_hide":"no","passster_area_shortcode":"","gtb_hide_title":false,"gtb_wrap_title":false,"gtb_class_title":"","gtb_remove_headerfooter":false,"footnotes":""},"categories":[1716],"tags":[1739,1997,1985,2020,491,1740,211,1988,1992,1990,1999,1998,2001,1984,1991,203,199,214,198,363,209,205,1745,1743,2014,222,2021,1989,2019,2012,1747,2007,2015,2000,196,212,2011,2004,2013,2009,2010,2017,2002,2018,2005,1994,1995,1986,1987,2003,2016,710,207,366,204,217,2022,1993,1996,288,1744,483,206,1741,1742,15921,1746,2008],"class_list":["post-339","post","type-post","status-publish","format-standard","hentry","category-c","tag-accentur-interview-questions-and-answers","tag-algorithm-to-find-lcm-of-n-numbers","tag-algorithm-to-find-lcm-of-two-numbers","tag-algorithm-to-find-lcm-of-two-numbers-in-c","tag-applied-materials-interview-questions-and-answers","tag-asian-paints-ltd-interview-questions-and-answers","tag-bosch-india-software-interview-questions-and-answers","tag-c-program-to-find-hcf-of-two-numbers","tag-c-program-to-find-lcm-of-2-numbers","tag-c-program-to-find-lcm-of-3-numbers","tag-c-program-to-find-lcm-of-3-numbers-in-c","tag-c-program-to-find-lcm-of-3-numbers-using-functions","tag-c-program-to-find-lcm-of-3-numbers-using-recursion","tag-c-program-to-find-lcm-of-n-numbers","tag-c-program-to-find-lcm-of-two-numbers-using-recursion","tag-capgemini-interview-questions-and-answers","tag-casting-networks-india-pvt-limited-interview-questions-and-answers","tag-cgi-group-inc-interview-questions-and-answers","tag-chetu-interview-questions-and-answers","tag-ciena-corporation-interview-questions-and-answers","tag-collabera-technologies-interview-questions-and-answers","tag-dell-international-services-india-pvt-ltd-interview-questions-and-answers","tag-dhfl-pramerica-life-insurance-company-ltd-interview-questions-and-answers","tag-elico-healthcare-services-ltd-interview-questions-and-answers","tag-find-lcm","tag-flipkart-interview-questions-and-answers","tag-flowchart-to-find-lcm-of-two-numbers","tag-flowchart-to-find-lcm-of-two-numbers-in-c","tag-gcd-and-lcm-in-c","tag-hcf-and-lcm-formulas","tag-hcl-technol-interview-questions-and-answers","tag-how-to-do-lcm","tag-how-to-find-lcm","tag-how-to-find-lcm-of-3-numbers-in-c","tag-ibm-interview-questions-and-answers","tag-indecomm-global-services-interview-questions-and-answers","tag-lcm-examples","tag-lcm-finder","tag-lcm-formula","tag-lcm-method","tag-lcm-of-12-and-18","tag-lcm-of-3-numbers","tag-lcm-of-3-numbers-in-c-using-function","tag-lcm-of-6-and-8","tag-lcm-of-fractions","tag-lcm-of-n-numbers-formula","tag-lcm-of-n-numbers-in-python","tag-lcm-of-two-numbers-in-c","tag-lcm-of-two-numbers-in-java","tag-lcm-program-in-clcm-meaning","tag-lcm-questions","tag-mavenir-interview-questions-and-answers","tag-mphasis-interview-questions-and-answers","tag-netapp-interview-questions-and-answers","tag-oracle-corporation-interview-questions-and-answers","tag-peoplestrong-interview-questions-and-answers","tag-program-to-find-lcm-of-3-numbers","tag-program-to-find-lcm-of-3-numbers-in-java","tag-program-to-find-lcm-of-n-numbers-in-java","tag-r-systems-interview-questions-and-answers","tag-raqmiyat-information-technologies-pvt-ltd-interview-questions-and-answers","tag-reliance-industries-ltd-interview-questions-and-answers","tag-sap-labs-india-pvt-ltd-interview-questions-and-answers","tag-tata-aia-life-insurance-interview-questions-and-answers","tag-tech-mahindr-interview-questions-and-answers","tag-telibrahma-interview-questions-and-answers","tag-the-linde-group-interview-questions-and-answers","tag-what-is-lcm"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to find LCM of two Numbers in C ? - C Interview Questions<\/title>\n<meta name=\"description\" content=\"How to find LCM of two Numbers in C ? - The LCM of two numbers a and b is the smallest positive integer that is perfectly divisible by both a and b (without a remainder)\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wikitechy.com\/interview-questions\/c\/how-to-find-lcm-of-two-numbers-in-c\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to find LCM of two Numbers in C ? - C Interview Questions\" \/>\n<meta property=\"og:description\" content=\"How to find LCM of two Numbers in C ? - The LCM of two numbers a and b is the smallest positive integer that is perfectly divisible by both a and b (without a remainder)\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/c\/how-to-find-lcm-of-two-numbers-in-c\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-12T21:04:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-14T05:52:29+00:00\" \/>\n<meta name=\"author\" content=\"Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/c\/how-to-find-lcm-of-two-numbers-in-c\/\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/c\/how-to-find-lcm-of-two-numbers-in-c\/\",\"name\":\"How to find LCM of two Numbers in C ? - C Interview Questions\",\"isPartOf\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\"},\"datePublished\":\"2021-07-12T21:04:03+00:00\",\"dateModified\":\"2021-09-14T05:52:29+00:00\",\"author\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757\"},\"description\":\"How to find LCM of two Numbers in C ? - The LCM of two numbers a and b is the smallest positive integer that is perfectly divisible by both a and b (without a remainder)\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wikitechy.com\/interview-questions\/c\/how-to-find-lcm-of-two-numbers-in-c\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757\",\"name\":\"Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g\",\"caption\":\"Editor\"},\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/author\/editor\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to find LCM of two Numbers in C ? - C Interview Questions","description":"How to find LCM of two Numbers in C ? - The LCM of two numbers a and b is the smallest positive integer that is perfectly divisible by both a and b (without a remainder)","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wikitechy.com\/interview-questions\/c\/how-to-find-lcm-of-two-numbers-in-c\/","og_locale":"en_US","og_type":"article","og_title":"How to find LCM of two Numbers in C ? - C Interview Questions","og_description":"How to find LCM of two Numbers in C ? - The LCM of two numbers a and b is the smallest positive integer that is perfectly divisible by both a and b (without a remainder)","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/c\/how-to-find-lcm-of-two-numbers-in-c\/","og_site_name":"Wikitechy","article_published_time":"2021-07-12T21:04:03+00:00","article_modified_time":"2021-09-14T05:52:29+00:00","author":"Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Editor","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/c\/how-to-find-lcm-of-two-numbers-in-c\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/c\/how-to-find-lcm-of-two-numbers-in-c\/","name":"How to find LCM of two Numbers in C ? - C Interview Questions","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"datePublished":"2021-07-12T21:04:03+00:00","dateModified":"2021-09-14T05:52:29+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757"},"description":"How to find LCM of two Numbers in C ? - The LCM of two numbers a and b is the smallest positive integer that is perfectly divisible by both a and b (without a remainder)","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/c\/how-to-find-lcm-of-two-numbers-in-c\/"]}]},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757","name":"Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g","caption":"Editor"},"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/editor\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/339","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=339"}],"version-history":[{"count":3,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/339\/revisions"}],"predecessor-version":[{"id":3642,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/339\/revisions\/3642"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}