Question
Complete as many of the following problems as you can by the end of class. Work in teams if you wish. Write a for loop
Complete as many of the following problems as you can by the end of class.
Work in teams if you wish.
- Write a for loop to sum all the integers between 1 and 100.
- In 1784, Carl Gauss solved problem #1 in seconds by noticing that:
1 + 99 = 100, 2 + 98 = 100, 3 + 97 = 100 (he was 7 years old at the time.)
Write a for loop to compute the sum in #1 using approximately half the number of executions of the for loop in #1.
- Write a program that outputs the sequence of numbers: 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121
- Write a program for problem #3 that does not use the multiplication operator (*).
(Hint: look at the difference between each number in the sequence of squares)
- Write nested for loops to produce this output:
1
2
3
4
5
- The first 12 Fibonacci numbers are: 1 1 2 3 5 8 13 21 34 55 89 144
Write a program to compute the first 12 Fibonacci numbers.
- Write nested for loops to produce the following output:
000111222333444555666777888999
000111222333444555666777888999
000111222333444555666777888999
- Write nested for loops to produce the following output:
1111111111
22222222
333333
4444
55
- Write nested for loops to produce the following output:
$
$$$
$$$$$
$$$$$$$
$$$$$$$$$
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started