I think CF has a logarithm function among its math functions.

To find out if a number x (x<>0) is a power of a number y (y<>1), you just have to 
check that the result of log(x)/log(y) is an integer;

PatNN




---------- Original Message ----------------------------------
From: "Jon Hall" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Date: Fri, 27 Oct 2000 13:37:54 -0400

>Thanks for all the responses guys! This is the one that struck me as
>best...why do it dynamically when all I need is the power of 3!
>
>thanks!
>
>...first Cold Fusion...then the World!
>
>jon
>----- Original Message -----
>From: <[EMAIL PROTECTED]>
>To: "CF-Talk" <[EMAIL PROTECTED]>
>Sent: Friday, October 27, 2000 1:06 PM
>Subject: RE: Power of 3
>
>
>> It's not very elegant, but the most efficient method (assuming it's always
>3
>> that you care about) might be to put all the values you care about into a
>> list in the application or request scope and do a listfind.  You can't
>have
>> that many entries before you hit the CF biggest-number limit.
>>
>> -----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]
>
------------------------------------------------------------------------------------------------
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