Created
July 19, 2012 13:39
-
-
Save linkmckinney/3143956 to your computer and use it in GitHub Desktop.
fizzcom
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfcomponent> | |
<cffunction name="processFizz" access="remote" returntype="String"> | |
<cfargument name="input" type="numeric"> | |
<cfset var local = structNew()/> | |
<cfset local.result = ''/> | |
<cfif arguments.input MOD 3 EQ 0 AND arguments.input MOD 5 EQ 0> | |
<cfset local.result = 'fizzbuzz'/> | |
<cfelseif arguments.input MOD 5 EQ 0> | |
<cfset local.result = 'buzz'/> | |
<cfelseif arguments.input MOD 3 EQ 0 > | |
<cfset local.result = 'fizz'/> | |
<cfelse> | |
<cfset local.result = arguments.input/> | |
</cfif> | |
<cfreturn local.result /> | |
</cffunction> | |
</cfcomponent> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfloop from="1" to="100" index="i"> | |
<cfinvoke component="fizzCom" method="processFizz" returnvariable="variables.result"> | |
<cfinvokeargument name="input" value="#i#"> | |
</cfinvoke> | |
<cfoutput>#variables.result#<br/></cfoutput> | |
</cfloop> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment