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
  Subtract 11 from entire list of quoted numbers Pleiades 1 77 Nov-14-2019, 10:26 AM
Last Post: Larz60+
  How to invert pixel numbers of MNIST data set squillam 1 157 Oct-16-2019, 11:18 AM
Last Post: scidam
  Prime numbers Anderi02 1 116 Oct-13-2019, 04:49 PM
Last Post: ichabod801
  Python regex to get only numbers tantony 6 169 Oct-09-2019, 11:53 PM
Last Post: newbieAuggie2019
  Issue with affecting numbers to a variable Adem 3 160 Sep-24-2019, 07:48 AM
Last Post: Adem
  List of numbers to add Planeuge 4 206 Sep-21-2019, 10:41 PM
Last Post: Planeuge
  I need a query to select the numbers that include 2 digits of 3 omidvakili 1 94 Sep-20-2019, 03:49 PM
Last Post: Yoriz
  Trouble converting numbers to characters Involute 4 188 Sep-12-2019, 04:49 AM
Last Post: Involute
  Working with Random Generated Numbers YoungGrassHopper 4 180 Sep-10-2019, 06:53 AM
Last Post: YoungGrassHopper
  Visual Studio Code does not print desired output but only prints "..." vincentolivers 11 335 Sep-09-2019, 12:58 PM
Last Post: vincentolivers

Forum Jump:


Users browsing this thread: 1 Guest(s)