Tuesday, November 16, 2010

Optimized Sieve of Eratosthenes

Sieve of Eratosthenes is a very good and famous method for finding a large number of primes. It is based on a general idea to flag out those numbers which are composite, and thus the numbers which remain are prime.

However, it can be optimized and there are a number of ways to do it.
There are many problems on Spoj, UVa that can be solved using sieve method.
One can extend general notion of sieve to solve other problems related to ETF, LCM, GCD, divisor summation etc.



Here is my code for it :-





The idea behind optimization is to leave those numbers which are divisible by 2 and 3.
It makes the sieve 3 times faster.


Here are some problems that can be tried with optimized sieve:

PRIME1
FINDPRM
CPRIME
TDKPRIME
TDPRIMES

Friday, June 11, 2010

Learning J2ME

Learning mobile programming is quite adventurous as you will find later on.

Mobile programmming can be done in a no. of languages, python looks very easy for this purpose.

However I am using J2ME, JSR 82 for my appication development.

If you are planning to run your application on nokia mobiles you need to know which SDK you will need. for example I have nokia 5130, and for that I use Nokia, series 40 fp1 lite.
you can find this information on http://www.forum.nokia.com/ .

you will have to download the sdk, ( Software development kit ), for your own mobile model.

For samsung mobiles check this ..
http://developer.bada.com/
They are organising samsung bada developer challenge, with total prize money of $2,700,000 . As you can see it is quite attractive.

hi all

This blog I will publish posts related to coding puzzles of UVa , topcoder , spoj.pl , codechef and various other , that I ma come around.

I will also like to post about some languages that I am learning which includes J2ME and python.

so keep coding.


Happy coding