Arithmetic series in the field of mathematics is the sequence number in which the next number of additions to the previous number by a number of specific differences. Examples are 3,5,7,9,11,13, ..... Arithmetic series can be expressed with the following formula:
a, a + b, a + 2b, a + 3b, ...
In this case the n-th quarter:
\ a_n = a + (n - 1) b,
The total of all quarters:
S_n = \ frac {n} {2} (a + a_n) = \ frac {n} {2} [2a + (n-1) b].
For example, the sum total of a quarter to quarter of an = 3 + (n-1) (5) up to a quarter-50 is
S_ {50} = \ frac {50} {2} [2 (3) + (49) (5)] = 6.275.
Algorithm deret aritmatika :
Deklarasi:
float a, b, n, un, sn: Integer
int x;
Deskripsi:
For ← (x = a, x <= un, x = x + b) a 1.0 ←, b ← 2.0; ← printf ("+% i ", x); EndFor write (Deret aritmatika)
following his program c + + :
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
//deklarasi data
float a,b,n,un,sn;
int x;
//badan program
printf("Program Penghitung Deret Aritmatika");
printf("\nMasukkan:");
printf("\nSuku ke n = ",n);
scanf("%f",&n);
a = 1.0;
b = 2.0;
un = a + (n-1)*b;
sn = (0.5*n)*(a+un);
printf("\nMaka Nilai dari Un = %f\n",un);
printf("\nNilai Sn = %f\n",sn);
printf("\nSelanjutnya\n");
printf("\nUn = %f\n",un);
printf("\nDeret aritmatika untuk %f adalah :\n\n",un);
for(x=a;x<=un;x=x+b) { printf("+%i ",x); } system("PAUSE"); return EXIT_SUCCESS; }
Tidak ada komentar:
Posting Komentar