Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Print Numbers starting at 1 vertically with separator for output numbers
#1
These numbers scroll vertically down my cmd screen after I hit execute from Geany. Is it possible for python to include numbers next to numbers with a separator, so I know which number to go to in the list? The imoge with the numbers below the sunglasses is what I hope for. Thanks anyone for the help.

Sad
262143
131071
65535
32767
16383

Cool
1)262143
2)131071
3)65535
4)32767
5)16383

Here is my code:

i = int(191561942608236107294793378084303638130997321548169216)
result = 0
while i >= 2 :
    print enumerate (i)
    i = i // 2
    
    result = result + 1
print (i //result)
print (result)
n = 191561942608236107294793378084303638130997321548169216//8
print (n)
Quote
#2
post your code in python tags. You should use enumerate() and some string formatting to get the desired output
Quote
#3
ok, it's bit different from what I expected.
i = 191561942608236107294793378084303638130997321548169216
result = 0
while i >= 2 :
    print(f'{result + 1: <3}) {i}')
    i = i // 2 # i //= 2
    result = result + 1 # result += 1
I am not sure if you would use result after you exit the loop
you may do also
i = 191561942608236107294793378084303638130997321548169216
result = 1
while i >= 2 :
    print(f'{result: <3}) {i}')
    i //= 2
    result += 1
or
i = 191561942608236107294793378084303638130997321548169216
result = 0
while i >= 2 :
    result += 1
    print(f'{result: <3}) {i}')
    i //= 2
Pleiades likes this post
Quote
#4
Thanks for the quick response buran, I was playing with perfect numbers, trying to reverse engineer them. lol
The problem is python cannot handle 100 mb outputs to well when calculating.

yet this one is easy

# Mersenne Prime Hunter
i = 496
result = 1
while i >= 2 :
    print(f'{result: <3}) {i}')
    i //= 2
    result += 1
print (result/2 +.5)
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Difficulty in understanding transpose with a tuple of axis numbers in 3-D new_to_python 0 80 Feb-11-2020, 06:03 AM
Last Post: new_to_python
  Printing output without print usage susmith552 1 139 Feb-07-2020, 07:52 PM
Last Post: Clunk_Head
  Removing Certain Numbers From File chascp 2 162 Feb-07-2020, 04:04 PM
Last Post: chascp
  Define a range, return all numbers of range that are NOT in csv data KiNeMs 18 523 Jan-24-2020, 06:19 AM
Last Post: KiNeMs
  output a list of random numbers 'x' columns wide adityavpratap 4 107 Jan-13-2020, 05:32 PM
Last Post: perfringo
  Can i prevent the random generator to generate already used numbers? MauserMan 3 143 Jan-05-2020, 04:44 PM
Last Post: MauserMan
  How do I name a list while generating numbers on the fly? Pleiades 6 233 Dec-03-2019, 05:47 PM
Last Post: jefsummers
  Generating numbers darktitan 3 223 Dec-01-2019, 06:25 PM
Last Post: darktitan
  How do I calculate a ratio from 2 numbers and return an equivalent list of about 1000 Pleiades 5 375 Nov-21-2019, 09:02 PM
Last Post: Pleiades
  Subtract 11 from entire list of quoted numbers Pleiades 1 149 Nov-14-2019, 10:26 AM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)