Functions – Math Tasks

You can find many interesting math / programming challenges at https://projecteuler.net/archives.

Input one number and return True for prime numbers and False for composite numbers.

Input a number and output all of the prime factors of that number. Example: 12 becomes [2, 2, 3] since 2x2x3 = 12.

Calculating the first n values of an infinite series: write a function that calculates \Sigma \cfrac{1}{x^2} for the first n values of x. For example, if n = 3, you would add up the first three terms like this:
\cfrac{1}{1^2} + \cfrac{1}{2^2} + \cfrac{1}{3^2}.

Simple Monopoly board game example: Create a function that inputs the user’s starting space and returns their ending space after rolling two dice and moving. The board has 40 spaces, so make their space a number from 0 to 39. If they go beyond space 39, they continue moving at space 0 to continue around the board. Bonus: add the rule for rolling again on doubles if you’d like.

Convert to Roman Numerals: input a base 10 number from 1 to 30 and output a string containing the Roman Numeral equivalent. This requires the use of “I”, “V”, and “X” characters for 1, 5, and 10.

Convert from Roman Numerals: write a function that inputs a Roman numeral that may contain “I” and “V” characters and returns the base 10 integer equivalent. Bonus: add in the ability to also read the “X” character.