Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Performing a math operation X amount of times

1573816398

Edited 1573816520
Hey, so I'm doing a thing where I have a number (let's take 256 as an example for ease of use), and I want to halve that number X amount of times, with X ideally being queried with a basic ?{halve how many times|0} prompt. Meaning if I entered 3, for example, the performed calculation would be [[(((256/2)/2)/2)]] with a result of 32. Is that even possible without API functionality? I have no idea how to start approaching it, as I can't find a way to perform an operation like that a variable amount of times while taking the results from previous iterations into account.
1573828537

Edited 1573828942
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
There's no way to do general iteration, but for that particular operation, you could use: [[256/2**?{number of halvings}]] That would basically raise the power of the divisor by 1 for each number of halvings: 2, 4, 8, 16... You could also prompt for the dividend: [[?{base number}/2**?{number of halvings}]] There are ways to handle other basic operations, but I don't know if you need those.