Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Algorithm to determine if a number A is a power of B.
#43
Is this what you were asking?

Code:
input "a = ", a
input "b = ", b

n = a
while ((n / b) = (n \ b))
    n = n / b
    if n = 1 then
        print a; " is a power of"; b
        sleep
        end
    end if
wend

print a; " is NOT a power of"; b
sleep

...only works with integers >= 1...
COUNT HACKED BY RAZVEEE

RAZVEE IS A SCRIPT KIDDIE- hacker9
Reply


Messages In This Thread
Algorithm to determine if a number A is a power of B. - by Lithium - 05-31-2005, 06:22 PM
Here's my effort - by Quibbler - 05-31-2005, 07:16 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)