Creating a complex donation system

Hello! Hope you’re having a good day. I’ve been trying to create a donation system where a user inputs an amount of Robux they would like to donate to the developer and then when they have to pay they will have to press and use the Roblox purchase prompt as little as possible.

My initial idea to solve this issue was to create a large array of Developer Products, 1 R$, 2R$, 5$, 10$, etc. And then solve to see what the least amount of prompts would require. This seems to be more complicated than I initially thought.

What I need help with is deciding the following:
Binary System
I would like to know what the most efficient way would be to create these developer products, have them increase exponentially in price, have them increase in regular amounts? I would just like some guidance to figure out the best method.

What I initially thought would be a suitable option is using powers of 2.
2^0 = 1
2^1 = 2
2^2 = 4
2^3 = 8
2^4 = 16
2^5 = 32
etc.

In this case, I could iterate over the digits in the binary number and prompt the corresponding amount when the binary digit is 1. This seems like a suitable approach and could very well be what I eventually use.

However, I’m not too sure whether this would be the most efficient and reasonable way to solve this problem.

Alternative Methods
My next train of thought was to have a few ‘common’ numbers, such as 1, 2, 5, 10, 20, etc. And then use modulus functions to get the ‘shortest’ way to the full number. However, I would not be sure what beginning numbers to use so that this is the most efficient method to use, so I decided not to go ahead with this one either.

If you could, a general idea of what you and your research have found regarding this topic or a similar topic would be great. No need for fully written out code or a full-on solution, but just a starting point would be more than enough!

Thank you very much!

3 Likes