# Function help needed

If you answering from the MATH forum, you can simply explain your solution rather than using code

I am writing a serial number program.

This will sound like a weird request, but I need a function that will return the following values:

values: 7 , 10, 27, 8, 19, 3 , 21, 30

I don't care what the function body does, so long as it returns those values.

The function parameter is a number from 0 to 9.

I am totally stumped. I just can't figure it out.

Thanks!

``````function Generate_Code( someInt ){

// Do something here that will return 7 ( the first number in my list )
.// based upon the parameter passed.

}``````

The reason I need those specific values is because they correspond to a keyphrase.

For MATH FORUM EXPERTS, I need ONE SINGLE algorithm that will return the values I listed above. So somehow, if I pass X to your algorithm, it will return 7. Then next time, I pass A DIFFERENT X , it will return 10, etc. I am interested in X, as it will be part of my serial number.
ozo

values: 7 , 10, 27, 8, 19, 3 , 21, 30
The function parameter is a number from 0 to 9.
Do you mean that you want
Generate_Code(0)==7,
Generate_Code(1)==10,
Generate_Code(2)==27,
Generate_Code(3)==8,
Generate_Code(4)==19,
Generate_Code(5)==3,
Generate_Code(6)==21,
Generate_Code(7)==30,
?
But there are two more input parameters from 0 to 9,  and we have run out of specified output values.  What do you want to happen with that?
I'm not sure I am understanding this question, but you did state, "I don't care what the function body does, so long as it returns those values" so here goes.  Try this function, and don't forget to include the global variable outside the function:

``````var \$index = 0;

function Generate_Code( \$someInt ){

\$array = array(7 , 10, 27, 8, 19, 3 , 21, 30);
\$output = \$array[\$index];
\$index++;
if (\$index > 7) \$index = 0;
return \$output;

}``````
The following is a math function which will have your eight numbers as roots.

f(x) = (x-7)(x-10)(x-27)(x-8)(x-19)(x-3)(x-21)(x-30) = 0
WTF?  Please do us all a favor and follow the guidance of the SSCCE, so we can see what you really want!  The description omits the information we need about the data structure and desired outputs.  As a result the responses will probably be suboptimal.
http://www.laprbass.com/RAY_temp_edvinson.php
``````<?php // RAY_temp_edvinson.php
error_reporting(E_ALL);

function EdVinson()
{
return array(7, 10, 27, 8, 19, 3 , 21, 30);
}

\$x = edvinson();
var_dump(\$x);``````
hielo

membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.