0

arithmetic progression and python

So basically i dont know how to write a code that calculates arithmetic progression that goes like (a1 = an * 2) i think the formula is like that but leme explain a1 = 1×2 = 2 a2 = 2x2 = 4. a3 = 3x2 = 6 a4 = 4x2 = 8 and i need to get to a64 so maybe there is a code that does it for me ?

17th Jan 2020, 9:59 PM
kasisX
kasisX - avatar
3 ответов
0
This is very simple, if I understand your explanation correctly. All you have to do is take a number, and multiply it by two. For example, here's a function: def arithmetic_progression(num): return num * 2 print(arithmetic_progression(64)) Output: 128 If you want to run this function over and over again until 128, all you have to use a for loop: for num in range(1, 129): print(arithmetic_progression(num))
17th Jan 2020, 10:38 PM
Jianmin Chen
Jianmin Chen - avatar
0
Aymane Boukrouh [INACTIVE] ...did a similar thing to what your trying to do...He did in his three lines of code code (see link) what would of taken me more than 52 lines....it'll give you an idea where to start... absolutly briliant. https://code.sololearn.com/cBVhBfHv3o63/?ref=app#py
18th Jan 2020, 12:17 AM
rodwynnejones
rodwynnejones - avatar
0
Thanks
18th Jan 2020, 8:04 AM
kasisX
kasisX - avatar