Find LCM of 2 Numbers
Duration: 4 min
This video lesson is available to enrolled students.
Inside: a video lesson and guided study material.
Module outline
- TCS One Shot Free Videos & Notes: TCS Preparation
- Numerical Ability (Foundation Section): Ratio and Proportion (Ratios), Divisibility Rules, Data Interpretation, Mixture and Alligation, Permutation and Combination, Logarithm, Number System, HCF LCM, Sequence and Series (Series), Speed Time and Distance, Percentage, Average, Powers and Exponents (Surds and Indices), Algebra, Probability, Profit and Loss, Simple Interest and Compound Interest, Time and Work, Pipe and Cistern, Mensuration and Geometry, Mental Ability, Age Problems, Statistics, Arithmetic, Partnership, Speed Mathematics and Basic Mathematics
- Reasoning Ability (Foundation Section): Series (Number and Letter Series) (Numerical Relations and Reasoning), Coding Decoding, Data Sufficiency, Non Verbal Reasoning (Spatial Aptitude) (Spatial Reasoning) (Visual Reasoning), Syllogisms, Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning), Seating Arrangements, Blood Relations, Directions (Direction Test), Analytical Reasoning (Counting Figures Reasoning), Puzzle Solving (Puzzles), Calendar, Clock, Cubes & Dices, Selection Decision Table (Decision Making), Crypt Arithmetic, Venn Diagram, Data Arrangement, Inequality, Analogy, Ranking, Order and Sequence, Logical Sequence Of Words
- New Pattern-Verbal Ability (Foundation Section): Sentence Completion (Fill in the blanks), English Writing Ability
- Old Pattern-Verbal Ability (Foundation Section): Vocabulary, Noun, Subject Verb Agreement (Verb Noun Agreement), Adjectives, Tenses, Pronoun, Preposition, Articles, Direct and Indirect Speech, Conjunction, Modals, Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing), Sentence Correction (Error Correction), Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions), Verbal Analogy (Word Based Analogy), Active Passive Voice (Voice), Determiner, Facts, Inference and Judgements, Adverb, Cloze Test (Cloze Passage), Sentence Construction, Verb
- Advanced Quantitative Ability: TCS NQT Advanced Quantitative Ability
- Advanced Reasoning Ability: TCS NQT Advanced Reasoning Ability
- Advanced Coding: Coding Questions by Yash Sir, C Programming by Yash Sir, Python for Placements by Yash Sir, DSA using Python, Object Oriented Programming (OOPS), Programming in C++, Java
- TCS Full Length Mock Test:
- TCS Interview & Resume Prep: MR & HR Interview Preparation, TCS Interview Preparation, Mock Interview, Interview Recordings, Resume Preparation, Resume Review
- Mega Test:
- Grand Test:
AI summary & chapters
AI Summary
An AI-generated summary of this video lecture.
This educational video, presented by a 'Placement Expert' from Knowledge Gate, teaches how to find the Least Common Multiple (LCM) of two numbers using programming. The lecture begins by defining the problem and providing sample input-output pairs. It then explains the mathematical logic of LCM using prime factorization, demonstrating the method with the numbers 15 and 25. The video transitions to a more efficient algorithm based on the formula LCM(a, b) = (a * b) / GCD(a, b). The core of the lesson is a step-by-step walkthrough of a C program that implements this solution, including a recursive function for calculating the Greatest Common Divisor (GCD) and a main function that takes user input and prints the result.
Chapters
0:00 – 2:00 00:00-02:00
The video opens with the Knowledge Gate logo, followed by a slide showing the organization's various educational channels. The main lecture begins with a problem statement on a digital blackboard: 'Q6: Write a program find LCM of two numbers'. The instructor, identified as 'Yash Jain Sir', presents sample inputs and outputs, such as Input: 15 20, Output: 60, to clarify the expected behavior. The core concept is introduced with the definition 'LCM = Smallest Number that divides both'. The logic is explained using prime factorization, with the example of 15 and 25. The prime factors of 15 are 5 and 3, and for 25 are 5 and 5. The LCM is found by taking the union of all factors, which is 5, 5, and 3, resulting in 75. The instructor emphasizes that the LCM is the product of the union of all prime factors.
2:00 – 3:37 02:00-03:37
The video transitions to a more efficient algorithm for finding the LCM. The instructor states that a simple solution is to find the prime factors and take their union, but an efficient solution uses the formula LCM(a, b) = (a * b) / GCD(a, b). The formula is written on the board, and the instructor explains that the GCD (Greatest Common Divisor) is the key to this method. The lesson then shifts to a C code implementation. A code snippet is displayed, showing the inclusion of the stdio.h header and the definition of a recursive function `int gcd(int a, int b)` which uses the Euclidean algorithm. The `int lcm(int a, int b)` function is shown to calculate the LCM using the formula. The `main()` function is presented, which takes two integers as input, calls the `lcm` function, and prints the result. The instructor then demonstrates the GCD calculation for a=6 and b=12, showing the recursive steps: `gcd(6,12)` calls `gcd(12%6, 6)` which is `gcd(0,6)`, and since a=0, it returns 6. This GCD value is then used to calculate the LCM.
The video provides a comprehensive, step-by-step guide to solving the LCM problem. It starts with a conceptual understanding of LCM using prime factorization, which is a fundamental but less efficient method. It then introduces a more practical and efficient algorithm based on the mathematical relationship between LCM and GCD. The core of the lesson is the implementation of this algorithm in C, with a clear, well-structured code example that includes a recursive GCD function. The instructor effectively bridges the gap between mathematical theory and programming practice, making the concept accessible for students preparing for coding interviews.

