+ 1
How do I create a range with both positive and negative integers, and print out the times table of the value N?
this is what I have so far. it needs to go from 0 to 12, or 0 to -12. so if N is 2 it needs to print 2,4,6,8,10,12. and if N is -2 needs to print out -2,-4,-6,-8,-10,-12. I can't figure it out. for ctr in range(1,12,N): if N < 0: ctr -= N print(ctr); elif N > 0: ctr += N print(ctr);
3 Respuestas
+ 1
thanks for the help guys. I was actually over thinking it. below is the proper way to write it...
N = 2
timesTable = {1, 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9, 10, 11, 12}
x = 0
for ctr in timesTable:
x = N * ctr
print(x);
0
Maybe you must to do it different even with a function
0
You should use something like
For int i = 1; i < 12; i++
If ( i mod N == 0) then
Print(i)