Sha256: 7760074673de7eec0321cf35ac629e878a6905c59e50be84699a5c02d11bf3b4

Contents?: true

Size: 579 Bytes

Versions: 74

Compression:

Stored size: 579 Bytes

Contents

/**
* Here is an example solution for the Grains exercise
*/
component {
	
	function square( input ) {
		if( input <= 0 || input > 64 ) {
			return -1
		}
		// Some of the test generate very large numbers which require a big integer or they lose precision
		var base = createObject("java","java.math.BigInteger").init( 2 );
		var power = createObject("java","java.math.BigInteger").init( input-1 );
		return base.pow( power ).toString();
	}
	
	function total( input ) {
		var total = 0;
		loop from=1 to=64 index='local.i' {
			total += square( i );
		}
		
		return total;
	}
	
}

Version data entries

74 entries across 74 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/cfml/exercises/grains/Solution.cfc
trackler-2.2.1.179 tracks/cfml/exercises/grains/Solution.cfc
trackler-2.2.1.178 tracks/cfml/exercises/grains/Solution.cfc
trackler-2.2.1.177 tracks/cfml/exercises/grains/Solution.cfc
trackler-2.2.1.176 tracks/cfml/exercises/grains/Solution.cfc
trackler-2.2.1.175 tracks/cfml/exercises/grains/Solution.cfc
trackler-2.2.1.174 tracks/cfml/exercises/grains/Solution.cfc
trackler-2.2.1.173 tracks/cfml/exercises/grains/Solution.cfc
trackler-2.2.1.172 tracks/cfml/exercises/grains/Solution.cfc
trackler-2.2.1.171 tracks/cfml/exercises/grains/Solution.cfc
trackler-2.2.1.170 tracks/cfml/exercises/grains/Solution.cfc
trackler-2.2.1.169 tracks/cfml/exercises/grains/Solution.cfc
trackler-2.2.1.167 tracks/cfml/exercises/grains/Solution.cfc
trackler-2.2.1.166 tracks/cfml/exercises/grains/Solution.cfc
trackler-2.2.1.165 tracks/cfml/exercises/grains/Solution.cfc
trackler-2.2.1.164 tracks/cfml/exercises/grains/Solution.cfc
trackler-2.2.1.163 tracks/cfml/exercises/grains/Solution.cfc
trackler-2.2.1.162 tracks/cfml/exercises/grains/Solution.cfc
trackler-2.2.1.161 tracks/cfml/exercises/grains/Solution.cfc
trackler-2.2.1.160 tracks/cfml/exercises/grains/Solution.cfc