Skip to content

Latest commit

 

History

History
12 lines (7 loc) · 1.35 KB

Readme.md

File metadata and controls

12 lines (7 loc) · 1.35 KB

Bonus Homework 01

This exercise assumes that you already solved the first homework and installed python and git. Once you cloned this git repository, make sure that you activate the conda-environment for the shell you use to run python in.

Make sure that your code of the bonus exercise and of the first regular homework are not mixed up! Every exercise has to be commited to the repository you originally pulled from.

Finding Prime Numbers

Your task for this exercise is to provide two functions, namely the function is_prime and the function find_prime. The first of those is supposed to take any natural number and return True if it is a prime number, and False otherwise. find_prime(7) for example is supposed to return True.

The find_prime method is supposed to find the nth prime number there is - which means find_prime(1) is supposed to return the first prime number there is, namely 2. The first six prime numbers being 2,3,5,7,11 and 13, find_prime(6) is supposed to return 13.

There are ways to find the nth prime number without having to test every single one from the first on (see for example this stackoverflow answer), but as you can see in the file test_prime.py, which contains the tests run by pytest, you need to implement both methods in order to pass the test.