Project: The Prime Number Calculator

Xenonsoft

Active Member
I've been learning a bit of JavaScript the past week and set myself a challenge of making a Prime Number Calculator that would be accurate to any number put in by the user.

Anyway, I've finished it and thought I'd let you lot know to see what you think, feel free to check it out or drop a comment on the site :)

DefaultYes - Prime Number Calc Complete

Cheers :up:

Note: It may well serve no purpose, but I enjoyed creating it and learnt a lot :D
Note2: Please let me know if there's any errors, I've done some checking over it so it should be fine though, tested up to the 10,000th prime.
 
Crashed my browser when attempting 100,000,000 :lol:
Didn't read the note at the bottom, wasn't expecting that there would be so many prime numbers :p
 
It is at the mo, gotta do some updates.

Fixed that bug, gotta fix the one that says pie is a prime :D

Any text string skips through currently, need to add a fix for that.

EDIT: My bad, thought you said 1 wasn't. That was coming up as a prime before, must have fixed that earlier. I lose track :D
 
mrp2049 said:
fred, this is cool, but 1 is a prime number too!
No, it's not actually :)
Although it qualifies the common rule (dividable by 1 and itself only) it interferes with the actual fundamental rule (where both divisors have to be different) and other rules that are based on prime numbers.
 
Prime Number -- from Wolfram MathWorld

Third paragraph of that explains why, decided not to paraphrase and just link it...

The number 1 is a special case which is considered neither prime nor composite (Wells 1986, p. 31). Although the number 1 used to be considered a prime (Goldbach 1742; Lehmer 1909, 1914; Hardy and Wright 1979, p. 11; Gardner 1984, pp. 86-87; Sloane and Plouffe 1995, p. 33; Hardy 1999, p. 46), it requires special treatment in so many definitions and applications involving primes greater than or equal to 2 that it is usually placed into a class of its own. A good reason not to call 1 a prime number is that if 1 were prime, then the statement of the fundamental theorem of arithmetic would have to be modified since "in exactly one way" would be false because any
Inline7.gif
. In other words, unique factorization into a product of primes would fail if the primes included 1. A slightly less illuminating but mathematically correct reason is noted by Tietze (1965, p. 2), who states "Why is the number 1 made an exception? This is a problem that schoolboys often argue about, but since it is a question of definition, it is not arguable." As more simply noted by Derbyshire (2004, p. 33), "2 pays its way [as a prime] on balance; 1 doesn't."
 
:lol:

Regarding the 1 malarky, I thought he said it was showing as a prime rather than not a prime, no need to fix that then.

Had it showing as a prime before so had to add in some other clauses.
 
Onartis said:
Crashed my browser when attempting 100,000,000 :lol:
Didn't read the note at the bottom, wasn't expecting that there would be so many prime numbers :p

haha!! did exactly the same for me! I had to close and re open my browser
 
Back
Top