It's Pi Day! This means we have at least 3.141592 reasons to think about pie, right? All of this while messing with our Raspberry Pis, and...okay, I'll stop. It's just that I like this number so much that I can't avoid being nerdy about it!

By the way, if you feel like memorizing the first one million digits of pi, this site can help you!

----

Anyway, as I was thinking about content to write for my next three posts about Creative Programming, one important concept came to my mind: recursive programming. I may be saying this just to throw you off though...who knows?

So, without further ado, the three Pi Day challenges:

**1.**In mathematics, the factorial of a positive integer n, denoted by n!, is the product of all positive integers less than or equal than n.

**Calculate the value of the sum of the first 314**

*odd digits*(digit 1 and digit 3 are the first two odd digits of the number 12345, for example) of 31415!

**2.**In number theory, a primorial (n#) is similar to the factorial, but with the product taken only over the prime numbers less than or equal to n.

**Calculate the primorial of 31415#**.

**3.**Determining whether a number is prime or not is a fairly interesting challenge. Throughout the years, many advances were made in that field. One of the famous calculations used in randomized primality tests is the Fermat test:

Let a be a random number between 2 and

*n*- 1, where

*n*is the number whose primality is being tested. Then,

*n*is probably prime if the following equation holds:

*a^n*mod

*n*=

*a*

If a number passes the Fermat test many times, the probability of it being a prime is very high. The bad news is that certain non-prime numbers still pass the Fermat test with every number smaller than themselves. These numbers are called Carmichael numbers.

**Determine the largest Carmichael number that is less than or equal to 31415.**

---

At a conversation last night with a friend online, we were talking about more complex math problems such as using Spigot algorithms to calculate pi, for example. I was even considering of including something of that nature, but I gave up. It is not time for complex challenges yet.

However, if you want something more spicy, feel free to send me an email and I'll be glad to give you a cool problem :D ricardo@iamprins.com.

Solutions will be posted anytime within the next three weeks or so. Or maybe before that, who knows.

0