Napisz program, który wygeneruje i wyświetli podany ciąg liczbowy:

1. 5-wyrazowy ciąg liczb całkowitych postaci (1, 3, 9, 27, 81)
2. 6-wyrazowy ciąg liczb całkowitych postaci (2, -4, 8, -16, 32, -64)
3. 5-wyrazowy ciąg liczb całkowitych postaci (19, 15, 11, 7, 3) i komunikat STOP

Proszę o szybką pomoc!!



Odpowiedź :

Odpowiedź:

1.

python

lista = []

for i in range(5):

   lista.append(3**i)

c++

#include <iostream>

#include <cmath>

using namespace std;

int main(){

for(int i = 0; i < 5; i++){

cout << pow(3, i) << " ";

}

cout << endl;

return 0;

}

2.

python

lista = []

for i in range(6):

   lista.append((-2 ** (i + 1)) * -1)

c++

#include <iostream>

#include <cmath>

using namespace std;

int main(){

for(int i = 0; i < 6; i++){

cout << (pow(-2, i+1)*-1) << " ";

}

cout << endl;

return 0;

}

3.

python

lista = []

for i in range(5):

   lista.append(19 - (i * 4))

print(lista)

c++

#include <iostream>

#include <cmath>

using namespace std;

int main(){

for(int i = 0; i < 5; i++){

cout << (19 - (i * 4)) << " ";

}

cout << endl;

return 0;

}