James Cassell's Blog

Tuesday, March 29, 2005

I finished and turned in my snake program.

I have been working on a prime number calculator. The first incarnation of it checked if it was divisible any number between itself and 1. That was very inefficient.

The next version of it had an array of calculated numbers. The number being checked was checked againsta all numbers in this array. This was reasonably faster.

I later thought of a way to exponentially increase the speed at which it processed the numbers by only checking numbers that were smaller than its square root. At this speed, it does the same amount of numbers in a fraction of the time.

I ran this program on my mom's brand new computer for about 15 hours. When I looked at the output after this time, I saw negative numbers. I realized that I had forgotten to declare the variables as unsigned. I fixed this problem and now have a program that will calculate all of the 32-bit prime numbers.

...Sort of unrelated, but I am on spring break this week. That is why I can stay up so late.

0 Comments:

Post a Comment

<< Home