Mathematical Script - Number Grid

Job ID: 32106613

Budget: $30 – $250 USD

hi i need someone good with maths scripts to help me build a number grid generator
the job is a little technical and must be done right.

once we set the rules in the code and press generate then it will start inserting numbers automatically into their positions on the grid.

i will tell the front end script the range of numbers e.g 1 to 10 and it will generate an excel style grid inserting the numbers 1 to 10 in their correct positions.

im inserting an excel file for 1 to 10 as an example so u can see what it would look like.

Rules:
- the number 1 is always in the top left square.
- a number directly above another number is HALF the number below it. i.e a number is TWICE the number above it.
- now for the other rule which is a little more complex. take a number x, e.g x = 3 then the number to the LEFT of X will be 3X + 1 , so if X = 3 then the number to its LEFT will be 10. as 3(3) + 1 = 10.
conversely a number to the RIGHT of Y is equal to (Y-1)/3 but note this wont work for all numbers (Y-1) must be divisible by 3. so it only works for numbers like 1, 4, 7, 10, i.e Y lives in 1 mod 3. but
- we only need to show 1 in the top left 1 time, and every number will appear only once.
e.g (4-1)/3 = 1 but we dont need to put 1 to the right of 4 as we already have it in the top left.

the number to the left of 5 is obviously 3(5)+1 = 16 but because we only set the range as 1 to 10 we dont need to insert 16. if i set the range as 1 to 16 then we will insert it. however this may cause error if the number is blank, so if u want u can insert all numbers and then highlight the ones in the range entered.


if it makes it easier u might wanna apply the rules as follows

if x is even divide by 2 and place x/2 above x. if x is odd then compute 3x+1 and place it to the LEFT of x.
then repeat for all numbers in the range and then stop.
we can show the new numbers generated from the numbers in the STARTING RANGE.
e,g 5 will generate 16 so its ok to show 16, 7 will generate 22, 9 will generate 28 etc we can show all these too if it makes coding easier.

Technical Point: if a square contains more than 1 number (and this will happen in general) then we comma seperate them inside the square.

Anything u dont understand ask me

id prefer this done in php but if u have other codes which are easier then tell me
Related categories: PHP JavaScript Python Excel Mathematics