ColdFusion Prime Number Generator
ColdFusion
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
org/orangexception/prime-number-generator
1.cfm
2.cfm
3.cfm
4.cfm
5.cfm
6.cfm
readme.md

readme.md

ColdFusion Prime Number Generator

I originally created 6 different prime number generators.

Recently, I created a Generator and Service to make it easier to use.

Original Post

http://orangexception.com/post/1419786549/i-made-a-couple-of-prime-number-generators

I made a couple of prime number generators. 6.cfm is the best.

Base Assumptions

Prime Numbers

  1. Prime numbers are positive integers.
  2. A prime number n is not evenly divisible by any value d, where 1 < d < n.
  3. 1 is not a prime number.
  4. 2 is a prime number.
  5. Except for 2, all prime numbers are odd numbers.
  6. 3 is a prime number.

Metrics

  1. Addition has a cost of 0.
  2. Division has a cost of 1. Division includes normal division and modular division.

My Process, the short version

I started simple. I reviewed my assumptions one at a time. I stopped when further modification to the algorithm increased run time.

The Algorithms

1.cfm First / Worst 2.cfm 3.cfm 4.cfm 5.cfm 6.cfm Last / Best

Last Assumptions

Prime Numbers

  1. An integer greater than one is prime if its only positive divisors are itself and one (otherwise it is composite).
  2. 1 is not a prime number.
  3. 2 is a prime number.
  4. 3 is a prime number.
  5. 5 is a prime number.
  6. Except for 2 and 5, prime numbers end with the digit 1, 3, 7, or 9.
  7. The number n is not evenly divisible by a number greater than the quotient of n / d.

Metrics

  1. Addition has a cost of 0.
  2. Division has a cost of 1. Division includes normal division and modular division.
  3. Structures have a cost of 9000. I dabbled into using structures to organize my variables, but it increased run time by a lot.