Find LCM Least Common Multiple of 3 and 5: List the Multiples of each number, The multiples of 3 are 3, 6, 9, 12, 15, 18,... etc The multiples of 5 are.

Slides:



Advertisements
Similar presentations
Def f(n): if (n == 0): return else: print(“*”) return f(n-1) f(3)
Advertisements

Maths & Trig, Statistical functions. ABS Returns the absolute value of a number The absolute value of a number is the number without its sign Syntax ◦
Divisor máximo de dois inteiros. unsigned int gcd(unsigned int A, unsigned int B) { if (B > A) return gcd(B,A); else if (B==0) return A; else return gcd(B,A%B);}
1 DATA ABSTRACTION: USER DEFINED TYPES AND THE CLASS.
CSE 311 Foundations of Computing I Lecture 13 Number Theory Autumn 2012 CSE
Chapter Primes and Greatest Common Divisors ‒Primes ‒Greatest common divisors and least common multiples 1.
BASIC FUNCTIONS OF EXCEL. Addition The formula for addition is: =SUM( insert cells desired to sum up ) This returns the sum of the selected cells.
1 Section 2.5 Integers and Algorithms. 2 Euclidean algorithm for finding gcd Where L is a larger number, and S is a smaller number, to find gcd(L,S):
Least Common Multiple (LCM)
Least Common Multiples
Martin-Gay, Beginning Algebra, 5ed
Python  By: Ben Blake, Andrew Dzambo, Paul Flanagan.
Programming Training Main Points: - Lists / Arrays in Python. - Fundamental algorithms on Arrays.
1 CSC 221: Introduction to Programming Fall 2012 Functions & Modules  standard modules: math, random  Python documentation, help  user-defined functions,
Now String theory To Do: Lists This stuff hurts my brane. when you learn string theory from google images… Goal: Thinking like a machine You should now.
CS1010E Programming Methodology Tutorial 1 Basic Data Type and Input/output, Characters and Problem Solving C14,A15,D11,C08,C11,A02.
>>> # Fibonacci series:... # the sum of two elements defines the next... a, b = 0, 1 >>> while b < 10:... print b... a, b = b, a+b WHILE.
Operators in Python. Arithmetic operators Some operators in Python will look familiar (+, -, *, /) Others are new to you (%, //, **) All of these do work.
Math 3121 Abstract Algebra I Lecture 9 Finish Section 10 Section 11.
Factoring using GCF interpret parts of an expressions such as terms, factors, and coefficient.
With Python.  One of the most useful abilities of programming is the ability to manipulate files.  Python’s operations for file management are relatively.
Functions. Built-in functions You’ve used several functions already >>> len("ATGGTCA")‏ 7 >>> abs(-6)‏ 6 >>> float("3.1415")‏ >>>
EECS 110: Lec 4: Functions and Recursion Aleksandar Kuzmanovic Northwestern University
We need a common denominator to add these fractions.
Least Common Multiple (LCM). Let’s Break It Down! Least  Smallest! Common  All numbers have it! Multiple  The product of a quantity! Definition:
Introduction to Computing Using Python for loop / def- ining a new function  Execution control structures ( if, for, function call)  def -ining a new.
Python Basics. 2 Python History Late 1970s: programming language called ABC at the Centrum voor Wiskunde en Informatica in the Netherlands Audience included.
Math Problems Francis Fok 9 th Oct. Content Greatest common divisor Prime number algorithm Find power Other forms of integer.
Lecture 4 Function example. Example1 int max (int a, int b) { int c; if (a > b) c = a; else c = b; return (c); } void main ( ) {int x, y; cin>>x>>y; cout.
By Austin Laudenslager AN INTRODUCTION TO PYTHON.
When finding multiples, you can list all of the products after multiplying it by 1, 2, 3, 4… Finding the Least Common Multiple For example, Multiples.
EECS 110: Lec 3: Data Aleksandar Kuzmanovic Northwestern University
COMPE 111 Introduction to Computer Engineering Programming in Python Atılım University
Math Problems Francis Fok.
3 Basics © 2010 David A Watt, University of Glasgow Accelerated Programming 2 Part I: Python Programming.
EECS 110: Lec 9: Review for the Midterm Exam Aleksandar Kuzmanovic Northwestern University
Introduction to Programming Python Lab 3: Arithmetic 22 January PythonLab3 lecture slides.ppt Ping Brennan
If/else, return, user input, strings
Math – Least Common Multiple 1. The __________________________ of two numbers is the ___________ number that is a __________ of both the original.
GCF / LCM Using Prime Factorization Tip to Remember: GCF should have a short string (only the shared factors) – factors are small LCM should have a long.
LESSON #8 LCM: Lowest Common Multiple. WHAT IS A MULTIPLE?  A multiple is what you get when you multiply by a number.  A multiple is a product of two.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Lesson 2-4 Example Find the LCM of 5, 9, and 15. Multiples of 5: 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, … Multiples of 9: 9, 18, 27, 36, 45, 54,
 Python for-statements can be treated the same as for-each loops in Java Syntax: for variable in listOrstring: body statements Example) x = "string"
Number Theory: Prime and Composite Numbers
Dictionaries Python.
Indentations makes the scope/block Function definition def print_message (): print “hello” Function usages print_message () hubo.move ()// hubo is a class.
Agenda Review:  Relation Properties Lecture Content:  Divisor and Prime Number  Binary, Octal, Hexadecimal Review & Exercise.
Introduction to Programming
Recall: d is a divisor of n  n % d == 0
For each pair of polynomials, find the least common multiple. Example For each pair of polynomials, find the least common multiple.
CSE 311 Foundations of Computing I
Introduction to Python
More Loop Examples Functions and Parameters
Introduction to Python
Lists in Python.
Finding the Least Common Multiple (LCM)
Least Common Multiples
3.1 Prime Factorization GCD and LCM 3.4 Equivalent Fractions and
Programming Training Main Points:
EECS 110: Lec 4: Functions and Recursion
LCM (lowest common multiples)
Python Basics with Jupyter Notebook
COMPUTER PROGRAMMING SKILLS
Least Common Multiple.
(3, 2) 2 -3 (-4, -3) -2 (5, -2) 1. a) Find: f(3) = ______
Trainer: Bach Ngoc Toan– TEDU Website:
More Basics of Python Common types of data we will work with
Hossain Shahriar CISC 101: Fall 2011 Hossain Shahriar
Finding the Least Common Multiple (LCM)
Presentation transcript:

Find LCM Least Common Multiple of 3 and 5: List the Multiples of each number, The multiples of 3 are 3, 6, 9, 12, 15, 18,... etc The multiples of 5 are 5, 10, 15, 20, 25,... etc

Find LCM def lcm(x, y): if x > y: greater = x else: greater = y while(True): if((greater % x == 0) and (greater % y == 0)): lcm = greater break greater += 1 return lcm

Find GCD Factors of 12 are 1, 2, 3, 4, 6 and 12 Factors of 30 are 1, 2, 3, 5, 6, 10, 15 and 30 Example: Factors of 12 and 30

Find GCD def gcd(x, y): if x > y: smaller = y else: smaller = x for i in range(1,smaller + 1): if((x % i == 0) and (y % i == 0)): gcd= i return gcd

Python’s Built-In Function Abs -- Find absolute value abs(-10) float, convert a string or a number to floating number int len - returns the length of an object max, min Range Sum: sum(list(range(0,5))