If I had an array of 7 numbers and I wanted all numbers to be equally spaced within it but needed to start at 5 and end at 35 how would I do this?
For instance if I were given:
- Numbers in array: 7
- Largest number in array: 35
- Smallest number in array: 5
How do I find what number to increment the array by if I wanted to create an array of equally spaced numbers?
An example answer would be: Given the above three numbers I would say increment each array position by 5 and all 7 numbers will be equally spaced all the way to 35. The end result would look like this: [5,10,15,20,25,30,35]
Question 1: What would the formula be to repeat this any time I have array length, smallest, and largest number?
Question 2: In the above example if I were given the number 30 what is the formula to find its position in the given array? The formula should produce a result like this: If the array started at index one it would be position 6.
Any help would be great, thanks!