Mathc initiation/Fichiers h : c66a5
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c00a.c |
---|
/* --------------------------------- */
/* save as c00a.c */
/* --------------------------------- */
#include "x_afile.h"
#include "fa.h"
/* --------------------------------- */
#define A_0 3.
#define A_1 5.
#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 :"
" 2**(n+1) +1 = %+10.0f\n\n", pow(2,TWENTY_TERM+1) + 1);
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 = 3
a_1 = 5
and a_k+2 = a_n(a_k+1, a_k) where
a_k+2 : k-> (3*(a_k+1) - 2*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 +3
a_1 +5
a_2 +9
a_3 +17
a_4 +33
a_5 +65
Press return to continue.
Exemple de sortie écran :
b) The sequence appears to converge to : 2**(n+1) +1 = +2097153
a_0 +3
a_1 +5
a_2 +9
a_3 +17
a_4 +33
a_5 +65
a_6 +129
a_7 +257
a_8 +513
a_9 +1025
a_10 +2049
a_11 +4097
a_12 +8193
a_13 +16385
a_14 +32769
a_15 +65537
a_16 +131073
a_17 +262145
a_18 +524289
a_19 +1048577
a_20 +2097153
Press return to continue.