# How do I.... random number but in 50 increments?

0 favourites
• 5 posts
From the Asset Store
You think you can guess the character’s name?! Then let’s see how smart you are!
• How do I have a random number between 100-600 but in increments of 50?

Currently I have: (random(round(100*0.05),round(600*0.05)))*150

but this is wrong.

• int(round(1-6)*100)

• Hmmm.. Doesn't seem to work. What I'm trying to do is spawn an object with X and Y coordinates. The suggestion doesn't seem to create random numbers between 100 - 600 in increments of 50. Instead, it seems to be subtracting 6 from 1 and then multiply by 100 every single time.

• int(random(0,11))*50 + 100

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• To explain 's correct help a bit more: In cases like these just think about what you're trying to achieve mathematically.

100 to 600 in 50's increments.

range you need: 600 - 100 = 500

steps you need: 500 / 50 = 10 => + 1 = 11 (the incremments plus starting at zero)

producing 11 numbers from 0 to 10 inclusive: int(random(0,11))//or shorter: int(random(11))

random(0, 11) produces floats that are higher than 0 and lower than 11, e.g. 0.023 or 10.98

int() omits the fractional part => 0.023 becomes 0, 10.98 becomes 10

0 to 10 * 50 => a range of 500 in 50's increments

+ 100 => shifting to the desired start value of 100

• 5 posts