G
gpy5504
1. Write a program which prompts the user to enter an integer between
1 and 9.
Based on the inputted number, the program outputs a triangular textual
shape using digits
(see below).
Sample Execution:
Enter N: 5
12345
1234
123
12
1
2.1. The Fibonacci sequence is a sequence of numbers beginning
1, 1, 2, 3, 5, 8, 13, 21, ...
The first two elements are defined to be 1. Each of the other elements
is the sum of its
two predecessors. Write a program that takes a value for N in the
range 1 to 30 and
displays the first N elements of the Fibonacci sequence.
Sample Execution:
Enter N: 9
Fibonacci sequence: 1 1 2 3 5 8 13 21 34
2. An integer P is called a prime number if the only positive integers
that divide P are
1 and P itself. Write a program which inputs a number N between 2 and
100 and then
loops through integers 2 to N and displays only those numbers which
are prime.
Sample Execution:
Enter N: 15
2 3 5 7 11 13
1 and 9.
Based on the inputted number, the program outputs a triangular textual
shape using digits
(see below).
Sample Execution:
Enter N: 5
12345
1234
123
12
1
2.1. The Fibonacci sequence is a sequence of numbers beginning
1, 1, 2, 3, 5, 8, 13, 21, ...
The first two elements are defined to be 1. Each of the other elements
is the sum of its
two predecessors. Write a program that takes a value for N in the
range 1 to 30 and
displays the first N elements of the Fibonacci sequence.
Sample Execution:
Enter N: 9
Fibonacci sequence: 1 1 2 3 5 8 13 21 34
2. An integer P is called a prime number if the only positive integers
that divide P are
1 and P itself. Write a program which inputs a number N between 2 and
100 and then
loops through integers 2 to N and displays only those numbers which
are prime.
Sample Execution:
Enter N: 15
2 3 5 7 11 13