Sha256: 44757196e1679505def5a100ac579c769b7d5d9fe93aa641ef9cc0741f0224af

Contents?: true

Size: 553 Bytes

Versions: 72

Compression:

Stored size: 553 Bytes

Contents

/**
* Here is an example solution for the NthPrime exercise
*/
component {

	function prime( input ) {
		if( input == 0 ) {
			return false;
		}
		var primes = [];
		var candidate = 1;
		while( primes.len() < input ) {
			candidate ++;
			if( candidate % 2 == 0 && candidate != 2 ) {
				continue;
			}
			var factor = 1;
			var isPrime = true;
			while( ++factor < candidate ) {
				if( candidate % factor == 0 ) {
					isPrime = false;
					break;
				}
			}
			if( isPrime ) {
				primes.append( candidate );
			}
		}
		
		return primes.last();
	}

}

Version data entries

72 entries across 71 versions & 1 rubygems

Version Path
trackler-2.2.1.104 tracks/cfml/exercises/nth-prime/Solution.cfc
trackler-2.2.1.103 tracks/cfml/exercises/nth-prime/Solution.cfc
trackler-2.2.1.102 tracks/cfml/exercises/nth-prime/Solution.cfc
trackler-2.2.1.101 tracks/cfml/exercises/nth-prime/Solution.cfc
trackler-2.2.1.100 tracks/cfml/exercises/nth-prime/Solution.cfc
trackler-2.2.1.99 tracks/cfml/exercises/nth-prime/Solution.cfc
trackler-2.2.1.98 tracks/cfml/exercises/nth-prime/Solution.cfc
trackler-2.2.1.97 tracks/cfml/exercises/nth-prime/Solution.cfc
trackler-2.2.1.96 tracks/cfml/exercises/nth-prime/Solution.cfc
trackler-2.2.1.95 tracks/cfml/exercises/nth-prime/Solution.cfc
trackler-2.2.1.94 tracks/cfml/exercises/nth-prime/Solution.cfc
trackler-2.2.1.93 tracks/cfml/exercises/nth-prime/Solution.cfc
trackler-2.2.1.92 tracks/cfml/exercises/nth-prime/Solution.cfc
trackler-2.2.1.91 tracks/cfml/exercises/nth-prime/Solution.cfc
trackler-2.2.1.90 tracks/cfml/exercises/nth-prime/Solution.cfc
trackler-2.2.1.89 tracks/cfml/exercises/nth-prime/Solution.cfc
trackler-2.2.1.88 tracks/cfml/exercises/nth-prime/Solution.cfc
trackler-2.2.1.87 tracks/cfml/exercises/nth-prime/Solution.cfc
trackler-2.2.1.86 tracks/cfml/exercises/nth-prime/Solution.cfc
trackler-2.2.1.85 tracks/cfml/exercises/nth-prime/Solution.cfc