Mathc initiation/Fichiers h : c66a6
Installer et compiler ces fichiers dans votre répertoire de travail.
c00b.c |
---|
/* --------------------------------- */
/* save as c00b.c */
/* --------------------------------- */
#include "x_afile.h"
#include "fb.h"
/* --------------------------------- */
#define A_0 0.
#define A_1 1.
#define SECON_TERM 2
#define FIVE_TERM 5
#define TWENTY_TERM 20
/* --------------------------------- */
/* --------------------------------- */
int main(void)
{
int n;
double a_0;
double a_1;
double a_2;
clrscrn();
printf(" If a sequence is defined recursively by a_0 = %.0f \n"
" a_1 = %.0f \n\n",
A_0, A_1);
printf(" and a_k+2 = a_n(a_k+1, a_k) where \n\n\n");
printf(" a_k+2 : k-> %s\n\n\n", a_neq);
printf(" a) Find the first five terms.\n\n");
printf(" b) What happens to the terms of the sequence as k increases.\n\n");
stop();
clrscrn();
printf(" a) The first five terms are :\n\n");
printf(" a_0 %+10.0f\n",A_0);
printf(" a_1 %+10.0f\n",A_1);
for(a_0=A_0, a_1=A_1, n=SECON_TERM; n<=FIVE_TERM; ++n)
{
a_2 = a_n(a_1, a_0);
printf(" a_%d %+10.0f\n", n, a_2);
a_0 = a_1;
a_1 = a_2;
}
stop();
clrscrn();
printf(" b) The sequence appears to converge to :"
" Fibonacci Sequence\n\n");
printf(" a_0 %+10.0f\n",A_0);
printf(" a_1 %+10.0f\n",A_1);
for(a_1 = A_1,
a_0 = A_0,
n = SECON_TERM; n <= TWENTY_TERM; ++n)
{
a_2 = a_n(a_1, a_0);
printf(" a_%d %+10.0f\n",n,a_2);
a_0 = a_1;
a_1 = a_2;
}
stop();
return 0;
}
/* --------------------------------- */
/* --------------------------------- */
Exemple de sortie écran :
If a sequence is defined recursively by a_0 = 0
a_1 = 1
and a_k+2 = a_n(a_k+1, a_k) where
a_k+2 : k-> (a_k+1) + a_k
a) Find the first five terms.
b) What happens to the terms of the sequence as k increases.
Press return to continue.
Exemple de sortie écran :
a) The first five terms are :
a_0 +0
a_1 +1
a_2 +1
a_3 +2
a_4 +3
a_5 +5
Press return to continue.
Exemple de sortie écran :
b) The sequence appears to converge to : Fibonacci Sequence
a_0 +0
a_1 +1
a_2 +1
a_3 +2
a_4 +3
a_5 +5
a_6 +8
a_7 +13
a_8 +21
a_9 +34
a_10 +55
a_11 +89
a_12 +144
a_13 +233
a_14 +377
a_15 +610
a_16 +987
a_17 +1597
a_18 +2584
a_19 +4181
a_20 +6765
Press return to continue.