Generate a non-similar number from previous generated numbers, between two numbers

41 Views Asked by At

I want to generate a number between two numbers that are always further away from the previously generated numbers.

For example, I want to generate numbers between 0 and 1. The first value would be 0.5 as that is furthest away from 0 and 1. Then it should generate something like: 0.25, 0.75, 0.125, 0.875, 0.375, 0.625, etc...

Or another example: generate a number between 1 and 100 could produce something like 49.5, 74.25, 24.75, 12.375, etc...

I'm guessing something like this has been done before but couldn't see anything around. If so what's it called? Otherwise, how would you build such a number generator?

One useful feature for such a generator is using this in programming to generate colours that are different from each other.

I'm new to this, so feel free to edit the question and the tags if you wish.

1

There are 1 best solutions below

4
On

You appear to be generating:-

The first odd number divided by 2

The first two odd numbers divided by 4

The first four odd numbers divided by 8

This should be very easy to program in whatever programming language you use.