Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

  1. Write a for loop to sum all the integers between 1 and 100.

  1. 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.

  1. Write a program that outputs the sequence of numbers: 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121

  1. 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)

  1. Write nested for loops to produce this output:

1

2

3

4

5

  1. 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.

  1. Write nested for loops to produce the following output:

000111222333444555666777888999

000111222333444555666777888999

000111222333444555666777888999

  1. Write nested for loops to produce the following output:

1111111111

22222222

333333

4444

55

  1. Write nested for loops to produce the following output:

$

$$$

$$$$$

$$$$$$$

$$$$$$$$$

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions

Question

What are the primary mission phases of operation?

Answered: 1 week ago

Question

Explain in detail why are financial systems are prone to crisis?

Answered: 1 week ago