Puzzle L15


For each integer N from 1 to 100 compute and print the sum 1+2+...+N

Write a main() program that computes and prints N sums: 1, 1+2, 1+2+3, ... , 1+2+3+...+N. There is a smart way to do this with just one loop, and a not-so-smart way that uses nested loops. Try to write the smart way from scratch.



Answer         Next Page         Previous Page Home