0

A program in C to print nth term of series 1 1 3 2 9 4 27 8 81 16........

at odd position there is a diff series and at even position there is a different one

3rd Sep 2018, 2:51 PM
shubhangi
4 Respostas
+ 6
shubhangi please let us know your query... note that people will not do entire coding for you.. if you are unable to get series , refer below : odd position is number at last position multiply by 3... so, you have 1,3,9,27,81 etc even position is number at last position multiply by 2.
3rd Sep 2018, 2:55 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 4
#in Python this is what I would do print(*[(2**(n//2) if n%2 else 3**(n//2)) for n in range(10)])
3rd Sep 2018, 3:20 PM
Louis
Louis - avatar
+ 3
shubhangi , refer below : int main() { int n = 10; int intLast_2=1; int intLast_3 =1; printf("%d\n",intLast_2); printf("%d\n",intLast_3); for(int i=1;i<(n/2);++i) { intLast_2 *= 2; intLast_3 *= 3; printf("%d\n",intLast_2); printf("%d\n",intLast_3); } return 0; }
3rd Sep 2018, 4:06 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
0
i know no one will do the entire coding. but i just want the idea to perfom this coding. the 2 different seriea i know them what the are at even places it is 2 to tha power 0 to n and at odd places it is 3 to the power 0 to n
3rd Sep 2018, 3:07 PM
shubhangi