Math is Hard

So remember that "Mersenne Prime Number Finder" that I talked about in my last post? Well as some of you have noticed it does not find Mersenne primes at all. It just finds regular old Mersenne numbers, which are of the form 2^n-1. Being a Mersenne number does not guarantee primality obviously, as the program returned results such as 15.

Thanks to the help of CRGreathouse, a moderator at Math Forum, I've realized these mistakes.
So, my goal is to find Mersenne Primes. I'm half-way there by finding regular Mrsn numbers... and luckily there is a thing known as the Lucas-Lehmer Primality Test, which applies only to Mrsn numbers. So now I have to find a way to implement this test into my program and I should be finding primes in no time!

CRGreathouse also introduced me to a programming language that is more suitable for numbers and mathematical operations than Java: Pari/GP. It is actually quite similar to Java in respect to syntax, but it handles numbers much more easily. Hopefully I'll be able to write my program soon! I have quite a bit to do today though and I'm working for most of the weekend, sadly.

Next week I'll have plenty of free time though, since I'm officially and finally done with summer classes. I'm not 100% sure that I passed Pre-calc... I did less than average on most of the quizzes and tests. I have no one to blame but myself, but this is just wrong. Here I am doing a math project in my spare time and yet I can't put forth the effort to pass a class? I don't lack the ability to understand the concepts, and I have an interest in math, but... I guess my fault lies in that I don't have an interest in doing homework. Oh well, as of now I'm still scheduled to take Calc I in fall semester, so hopefully that doesn't fall through even if I don't pass. I do NOT want to retake precalc and sit through 15 weeks of the same stuff I just learned.

Haha, well here's to slacking off and getting nowhere!
read more

Prime Numbers

Have you ever had one of those days when you wake up thinking about prime numbers?
Of course you have! Everyone has! Today, that was me. I rolled out of bed and stumbled over to my computer to find out about prime numbers.

For those of you unacquainted with theoretical mathematics, a prime number is a natural number that can only be divided by itself and 1. Here's more information about prime numbers if you are interested.

Anyways, its theorized that there are an infinite number of primes. When they start getting larger, you run into numbers known as Mersenne Primes. These are prime numbers that can be expressed in the form (2^n)-1. It was these prime numbers that grabbed my attention this morning. I wondered just what some of these numbers were, and the fact that there are lots of people trying to find larger and larger Mersenne Primes intruiged me. I thought to myself, "Why, if they can do it, so can I!"

So I set about writing a simple program in Java. It asks the user how many Mersenne Primes they would like to find and then spits out all the numbers of the form (2^n)-1. The problem is that in Java, there is a limit to how big a number value can be, and when dealing with java's basic exponent function (java.lang.Math.pow(x,y);) this peaks at the value limit for integers. Therfore the most Mersenne Primes you can find with my program is 30.

So here are the first 30 Mersenne Primes (1 is on the list but I don't count it because I know its not a prime number):


My code:
/* Prime Number Finder
* Created by Tyler Ash
* (c) August 12 2009
* --------------------
* Searches for prime numbers within a user defined amount of numbers starting at 1.
import java.util.Scanner;
public class PrimeFinder
public static void main(String args [])
int a = 1;
double k;
int n;
Scanner input = new Scanner(System.in);
System.out.println("Welcome to Mersenne Prime Number Finder. This program searches for Mersenne primes within a given amount of numbers, starting at 1.\nHow many numbers do you want to search?\n");
n = input.nextInt();
if (n<1)
System.out.println("Please enter a number greater than 1.\n");
n= input.nextInt();
k= java.lang.Math.pow(2,a)-1;
System.out.println("\nSearch for the first " + n +" Mersenne Prime Numbers competed.");

Oh, and I got a haircut today.
read more

Not Good at Goodbyes

I had to say goodbye to my girlfriend this morning as she left for school in Chicago. We did a lot of fun stuff over the summer, but its hard to know that there won't be any more hugs or kisses for a long time. We talk online or call eachother every night, and I randomly send flowers to her dorm address to let her know I'm thinking of her.
Chicago is such a cool city- I'm jealous. Its good to have an excuse to visit the Windy City though!
This was just a short post, but I wanted to say what has been in my mind all day.

read more

Dungeons & Dragons

Recently I've had the pleasure of playing in my friend's Dungeons and Dragons game. Its a 10th- level adventure called "Touch of Madness." There is a group of 6 or 7 of us, and we've been able to get together for two sessions so far.

The adventure so far has been cool- it started off with a bang, throwing our characters into a pitched battle against some ferocious Grells (floating, tentacled brain- monsters). My character is a 10th- level Deva Wizard named Tavar Deathgaze. Pretty sweet, I know. Fourth edition is cool, and we were able to make use of the DnD Insider tools to make our characters, but this adventure is the first game of DnD for several people at the table, so I think that starting off at 10th level was not such a great idea. The powers and abilities at first level are still pretty cool. Being at such a high level with so many different abilities and powers and no idea of how to use them has definetly caused the party to move very slowly. In our two sessions we've managed to get through only two encounters. Our party has only now finally come to the Forlorn Tower- the first dungeon in the adventure.

I've got to give props to our DM though. He's got a lot of patience to be able to deal with the group of us. We have a problem of just talking and going off-topic and debating this and that detail of the game. Only one other person and I have experience playing aside from the DM, so we often have to help focus the game. The other experienced player actually pulled me aside and invited me to play another game with other experienced players later this week. It would be fun to join a game like that, even if only for a one-shot.

My core rulebooks for 4E DnD. Oh, what's that? A natural twenty? Yes sir.

This experience of actually playing has given me hope. I started writing a 4th-ed adventure last winter, and now I've given some thought to completing it because I think it might be possible to get a group together and give DM-ing a shot.

We'll see. I also want to finish my NWN mod, which I have been slowly but surely working on piece by piece over the last week or so.

I still have a few more math classes to go, so I need to focus on that for now. Hopefully I get a good enough grade to move on to Calc I in the fall semester.
read more