1 + 1/2 + 1/3 + ... + 1/n + ...
The n-th partial sum is what you get by
adding up the first n terms. Type in and run the
program sum.c to compute the n-th partial sum
for n = 10, n = 100, n = 1000, and n = 10,000. Graph
the partial sums and say what you can about their growth
as n increases.
Consider next the question of whether the partial sums approach a limit L. This happens if the n-th partial sum s(n) gets closer and closer to L as n gets larger and larger. In this case we say that the series converges. In the contrary case we say that it diverges . One way a series can diverge is by getting larger and larger, with out bound. In other words, for any number A that you pick, I can find an integer N such that s(n) > A if n > N. In this case we say the series diverges to infinity.
The harmonic series diverges to infinity. This fact was already known in the fourteenth century to Nicolas Oresme , a thirteenth century Scholastic philosopher. Given what was known at the time, his argument must have been quite elementary. Can you find it?
Type in the program using the cat command:
% cat >hello.c
#include <stdio.h>
main()
{
printf( "Hello world!\n" );
}
<control-D>
Verify that the program is there:
% ls hello.c
hello.c
Check that the program text is OK using cat
a different way:
% cat hello.c
#include <stdio.h>
main()
{
printf( "Hello world!\n" );
}
Compile the program:
% gcc -o hello hello.c
Now the program has been translated from
C to machine language. The machine language
version is stored in the file hello.
To run this program we type its name:
% hello
Hello world!
To write more elaborate programs you should learn to use a text editor, e.g., emacs . The best way to do this is to type the command emacs , then type C-h t (control-h followed by ordinary t). This will put you in the online emacs tutorial.