would this work:


<CFSET x = randrange(3, 10)>The random number is:
<CFOUTPUT>
#x#

<BR>
<CFIF x MOD 3 IS 0>
        <CFSET x = x / 3>
went one stage: #x# <br>
        <CFIF x MOD 3 IS 0>
                <CFSET x = x / 3>
went two stages: #x# <br>
                <CFIF x MOD 3 IS 0 or x eq 1>
                a power
                <CFELSE>
                </CFIF>
        <CFELSE>
        </CFIF>
<CFELSE>
</CFIF>
</CFOUTPUT>



-----Original Message-----
From: Simon Horwith [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 27, 2000 11:47 AM
To: CF-Talk
Subject: RE: Power of 3


<CFIF yourvariable MOD 3 IS 0>

~Simon

-----Original Message-----
From: Jon Hall [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 27, 2000 12:36 PM
To: CF-Talk
Subject: Power of 3


Anyone have an idea on how to check to see if a value is a power of 3?

I have a loop that needs to fire an event at every power of three that it
hits and I am having problems getting my brain around how I need to do this.
My first thoughts are to have a loopcounter and each time around the counter
is incremented check and see if the counter value is the Next power of
three.
The end effect is that the if statement is triggered the following
intervals: 3,9,27,81...

jon

----------------------------------------------------------------------------
--------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a
message with 'unsubscribe' in the body to [EMAIL PROTECTED]
----------------------------------------------------------------------------
--------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a
message with 'unsubscribe' in the body to [EMAIL PROTECTED]
------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]

Reply via email to