Do a search for how to write a for-loop in R. Practice some simple examples from the internet.
Then use a for-loop to calculate the alternating sum of the first 100,000 digits of pi. That is, calculate the sum 3 - 1 + 4 - 1 + 5 - ... - (100,000th digit of pi). [code, answer]