As usual, write in your diary as you do the following exercises.
Optional this time, required soon, and highly
recommended. Write your homework in LaTeX and include your Python
code and testing in the document. Use my solution
to homework 2
(www.cs.umb.edu/~eb/480/hw02/)
as a model - start with that TeX file, keep all the TeX preliminaries
and the structure, then edit the content starting with
\begin{document}
. If you read my content you can see how to get
all the cool formatting.
If you've used TeX before, this is a requirement now. If you haven't, it's time to try to get started. This is not "extra work" since TeX is one of the software tools for mathematics this course is meant to teach you. To get started you will need a TeX distribution (that's like getting python for your computer) and a TeX editor (think of that as an IDE for TeX, like pycharm for Python). You can find what you need at the (TeX resources link on the course home page.
def myfunction(parameters): """ Documentation here, with lines delimited by triple quotation marks """ # function body return something
def eulerphi( b ): """ Given a positive integer b, returns a list of the integers between 1 and b that are relatively prime to b. For example, eulerphi(15) returns the list [1,2,4,7,8,11,13,14] Use the function gcd from the fractions library. """
def primeslessthan(b): """ Return a list of the primes less than the positive integer b. """Since
b
won't be very large (say no bigger than 1000)
you can call eratosthenes.py
for this, or create a file
of primes (easy from the web) and read it.
def fsf(n, b): """ Find and return the smallest factor of n: Get the list L Lof primes less than or equal to b. See if any of the primes in L is a factor of n. Calculate M, the product of the primes in L, Loop up to sqrt(n) testing only possible factors of the form kM + j for j in eulerphi(M) with k = 1, 2, ... """