Hands-on session 1 : Simple code

14 views
Skip to first unread message

Umesh Mohan

unread,
Jul 6, 2014, 10:07:43 AM7/6/14
to pn...@googlegroups.com
Dear All,

In today's hands on session I had hoped to pick a biologically relevant problem and have a go at it. Instead I wrote simple codes to
1) compute N prime numbers / prime numbers till N
2) writing and reading csv files

I started out with writing an algorithm for computing N prime numbers:
1) start with a list of primes containing the number 2
2) take the next number
3) see if it is divisible by any number less than itself
4) if it is not divisible, then this number is prime
5) if you don't have N prime numbers, go back to step 2

We modified the code to compute prime numbers till N instead of N primes : https://gist.github.com/umeshmohan/7c66a51857cc4f74b703

Exercise : Translate the algorithm "Sieve of Eratosthenes" (https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes) into a program to compute prime numbers till N

Feel free to write to me if you are stuck at any point.

Best,
Umesh Mohan
Reply all
Reply to author
Forward
0 new messages