void printxs(int xs[], int len)
{
int i;
i = 0;
while (i < len)
{
printf("%d, ", xs[i]); i = i + 1;
}
printf("\n");
}
void nat(int xs[], int len)
{
int i;
i = 0;
while (i < len)
{
xs[i] = i;
i = i + 1;
}
}
void evenSeq(int xs[], int len)
{
int i;
i = 0;
while (i < len)
{
xs[i] = i * 2;
i = i + 1;
}
}
void oddSeq(int xs[], int len)
{
int i;
i = 0;
while (i < len)
{
xs[i] = (i * 2) + 1;
i = i + 1;
}
}
void squareSeq(int xs[], int len)
{
int i;
i = 0;
while (i < len)
{
xs[i] = i * i;
i = i + 1;
}
}
void sqrootSeq(int xs[], int len)
{
// sqrt(x)
int i;
i = 0;
while (i < len)
{
xs[i] = sqrt(i);
i = i + 1;
}
}
void fib(int xs[], int len)
{
// 0、 1、 1、 2、 3、 5、 8、 13、 21、 34、 55、 89、 144、 233、 377、 6
int i;
xs[0] = 0; xs[1] = 1;
i = 2;
while (i < len)
{
xs[i] = xs[i - 1] + xs[i - 2];
}
}
void lucas(int xs[], int len)
{
// 卢卡斯数 (Lucas Number):
// 2、 1、 3、 4、 7、 11、18、 29、 47、 76、 123、 199、 322、
//why the Lucas numbers are amazing is that first, it cannot be divided by 5 or 13;
//second, it cannot be divided by a Fibonacci number except by 1,2, and 3;
//third, it follows a 12-cycle length pattern. If you look at the given sequence above,
//it repeats the sequence after the 12th number in the sequence.
int i;
xs[0] = 2; xs[1] = 1;
i = 2;
while (i < len)
{
xs[i] = xs[i - 1] + xs[i - 2];
}
}
void pell(int xs[], int len)
{
// 佩尔数 (Pell Number):
// 0、 1、 2、 5、 12、 29、 70、 169、 408、 985、 2378、 5741
int i;
xs[0] = 0; xs[1] = 1;
i = 2;
while (i < len)
{
xs[i] = xs[i - 2] + xs[i - 1] * 2;
}
}
void pellLucas(int xs[], int len)
{
// 佩尔 - 卢卡斯数 (Pell - Lucas Number):
// 2、 2、 6、 14、 34、 82、 198、 478、 1154、 2786、 6726等。
int i;
xs[0] = 2; xs[1] = 2;
i = 2;
while (i < len)
{
xs[i] = xs[i - 1] + xs[i - 2] * 2;
}
}
void perrin(int xs[], int len)
{
// The Perrin sequence, on the other hand, will look like this:
// 3, 0, 2, 3, 2, 5, 5, 7, 10, 12, 17, 22, 29, 39, 51, 68, 90, 119, 158 and so on.
int i;
xs[0] = 3; xs[1] = 0; xs[2] = 2;
i = 3;
while (i < len)
{
xs[i] = xs[i - 2] + xs[i - 3];
}
}
void padovan(int xs[], int len)
{
// A Padovan sequence will look this:
// 1, 1, 1, 2, 2, 3, 4, 5, 7, 9, 12, 16, 21, 28, 37 and so on.
int i;
xs[0] = 1; xs[1] = 1; xs[2] = 1; xs[3] = 2;
xs[4] = 2;
i = 5;
while (i < len)
{
xs[i] = xs[i - 3] + xs[i - 4] + xs[i - 5];
}
}
void ratioOf(int xs[], int len)
{
// try this on padovan and perrin sequence
// ratio between the consecutive terms approach a limiting value called a plastic constant. In mathematics,
// a plastic constant is an irrational number and the real-valued root of the cubic equation x^3 - x - 1 = 0.
}
int sum(int xs[], int len)
{
int i, res;
i = 0; res = 0;
while(i < len){
res = res + xs[i];
}
return res;
}
int prod(int xs[], int len)
{
int i, res;
i = 0; res = 1;
res = res * xs[i];
return res;
}
float avg(int sum, int len)
{
return (float)sum/len;
}
void reverse(int xs[], int len)
{
int i, j, t;
i = 0; j = len - 1; t = 0;
while (i <= j)
{
t = numbers[i];
numbers[i] = numbers[j];
numbers[j] = t;
}
}
float dev(int xs[], int len)
{
// sqrt(variance / len)
// sqrt is in math.h
// variance = sumOf pow(xs[i] - avg, 2)
int i, sum;
float average, diff, res;
i = 0; sum = 0;
while (1)
{
}
while (1)
{
}
res = sqrt(res / len);
return res;
}
int main()
{
int len;
len = 5;
int xs[len];
oddSeq(xs, len);
printxs(xs, len);
return 0;
}