csci 246 – class 2mdale/courses/csci246/slides/csci 246 - cla… · csci 246 –class 7 proofs...

Post on 08-May-2020

1 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

CSCI 246 – Class 7PROOFS

Plan for today:

- Quiz

- Normal review of video lesson (Euclidean Algo)

- Quiz question over video

- Review

- Homework

- Python IDE Demo

- Break – Download preferred IDE

- Python

Quiz Questions

Lecture 13:

Remember that Euclidean Algorithm is:

Function gcd(a,b)

If(a<b) return gcd (b,a)

If (b=0) return a

Else return gcd(b, a mod b)

Step through the algorithm gcd of gcd(57, 9):

Notes

Have a good weekend

Lesson 13

Lemma:

Let a>b

By the Quotient – Remainder Theoerm: a=q*b+r

=> r = a mod b

Then GCD (a,b) = GCD(b,r)

Lesson 13

Lemma:

Let a>b

By the Quotient – Remainder Theoerm: a=q*b+r

=> r = a mod b

Then GCD (a,b) = GCD(b,r)

Lesson 13

Proof:

1) let d|a and d|b

Lesson 13

Proof:

1) let d|a and d|b

a=u*d b=v*d

Lesson 13

Proof:

1) let d|a and d|b

a=u*d b=v*d

r = a-q*b = (ud)-q*(v*d) =(u-qv)d

Lesson 13

Proof:

1) let d|a and d|b

a=u*d b=v*d

r = a-q*b = (ud)-q*(v*d) =(u-qv)d

=> d|r

Lesson 13

Euclid or Euclidean's Algorithm

Function gcd(a,b)

If (a<b) return gcd(b,a)

If (b=0) return a

Else return gcd(b, a mod b)

Homework (Group)

Walk through Euclidean's Algorithm for the following:

1. gcd(24, 60)

2. gcd(24, 105)

3. gcd(60, 7)

Homework (Individual)

Walk through Euclidean's Algorithm for the following:

1. gcd(4, 14)

2. gcd(14, 4)

3. gcd(14, 89)

Demo

Python IDEs

Visual Studio Express with Python Plug-in

Pycharm

Break

Python IDEs

Visual Studio Express with Python Plug-in

https://www.visualstudio.com/en-us/downloads/visual-studio-2015-downloads-vs.aspx

https://pytools.codeplex.com/

Pycharm

https://www.jetbrains.com/pycharm/

Awesome resources

First Learning

Learn Python the Hard way: http://learnpythonthehardway.org/book/

Check IO Game: http://www.checkio.org/

References:

Hitchhiker’s Guide to Python: http://docs.python-guide.org/en/latest/

Python.org: https://docs.python.org/3/

top related