Find LCM of 2 Numbers

Duration: 4 min

This video lesson is available to enrolled students.

Return to /learn/AMCAT-PREPARATION/codingautomata-round/coding-questions/coding-question/asset-find-lcm-of-2-numbers after enrolling

Inside: a video lesson and guided study material.

Module outline

  1. Quantitative Ability: Percentage, Profit and Loss, Ratio and Proportion (Ratios), Average, Time and Work, Speed Time and Distance, Simple Interest and Compound Interest, Age Problems, Number System, Divisibility Rules, HCF LCM, Algebra, Permutation and Combination, Probability, Data Interpretation, Logarithm, Sequence and Series (Series), Powers and Exponents (Surds and Indices), Speed Mathematics and Basic Mathematics
  2. Logical Reasoning: Seating Arrangements, Puzzle Solving (Puzzles), Data Arrangement, Coding Decoding, Blood Relations, Directions (Direction Test), Ranking, Order and Sequence, Data Sufficiency, Venn Diagram, Inequality, Series (Number and Letter Series) (Numerical Relations and Reasoning), Logical Sequence Of Words, Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning), Selection Decision Table (Decision Making), Analogy, Non Verbal Reasoning (Spatial Aptitude) (Spatial Reasoning) (Visual Reasoning)
  3. Verbal Ability: Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions), Subject Verb Agreement (Verb Noun Agreement), Tenses, Articles, Preposition, Conjunction, Modals, Active Passive Voice (Voice), Direct and Indirect Speech, Vocabulary, Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing), Sentence Completion (Fill in the blanks), Sentence Correction (Error Correction), Cloze Test (Cloze Passage), Facts, Inference and Judgements
  4. Programming Fundamentals (Technical): C Fundamentals
  5. Data Structures (Technical): Introduction to DS, Array, Stack, Queue, Linked List, Tree, Graphs, Hashing
  6. Algorithms (Technical): Algorithm Analysis, Sorting Algorithms, Greedy Algorithms, Dynamic Programming, Minimum Spanning Trees, Shortest Path Algos, Time Complexity Analysis, Advanced Algorithms
  7. OOPs (Technical): Object Oriented Programming (OOPS)
  8. DBMS (Technical): Basics of DBMS, ER Diagram, Relational Model & Functional Dependencies, Keys & Integrity Constraints, Normalization (1NF - BCNF), Decomposition Properties & 4NF, File Organization & Indexing, Relational Algebra, Relational Calculus, Transaction Management, Concurrency Control, Database Recovery, ORDBMS, Database Security & Authorization, Query Processing & Optimization, Enhanced Data Models, Data Warehousing & Mining, Big Data Systems, NoSQL
  9. SQL (Technical): SQL
  10. Operating Systems (Technical): Introduction to OS, Process Management, CPU Scheduling, Process Synchronization, Deadlock, Threads & Process Creation, Memory Management, Virtual Memory, Disc Scheduling, File Management, Windows OS, Linux OS, Security, Distributed Systems, Virtual Machines
  11. Computer Networks (Technical): Introduction to CN, Data Communication, DLL: Access Control, DLL: Flow Control, DLL: Error Control, DLL: Framing, Data Link Layer - Ethernet, Net Layer: IPv4 & Proto, Net Layer: IP Addressing, Net Layer:Routing Protocol, Transport Layer Services, TL: Congestion & UDP, Application Layer, Hardware basics, Network Security, Cloud Computing and IoT, Cyber and Info Security
  12. Software Engineering (Technical): Fundamentals of Software Engineering, Software Requirements and Quality Assurance, Software Design, Estimation and Metrics, Software Testing, Software Maintenance and Configuration Management
  13. Coding/Automata Round: Coding Questions by Yash Sir, C Programming by Yash Sir, Programming in C++, Java, Python for Placements by Yash Sir, Pseudo Codes
  14. Personality / Behavioral Assessment: Behavioral Assessment (Behavioral Competency Profiling) (Psychometric Test)
  15. Writing Assessment: English Writing Ability
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

  1. 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. 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.

Loading lesson…