Python Forum
how do I show 12 numbers from a huge number?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how do I show 12 numbers from a huge number?
#16
(Sep-02-2019, 02:50 PM)jefsummers Wrote: It can certainly be done. I've been trying to figure an easier way than this, but here is one certain way:
1. create a list. The elements of this list will reflect the individual digits of your number. Initialize this list to 2.
2. Calculate 2**34.
3. Create a loop 1 to 2**34. In that loop you will multiply the current value (represented by the list) by 2. You will perform the multiplication the way you did in 3rd grade - multiply by the first digit, if greater than 10 then subtract 10 to keep the digit in range and carry the 1. Then multiply the next digit and add the carry until you have multiplied by all the digits. If there is a carry on the last digit add an element with the value of the carry (1).
4. Test this with a short loop to make sure it is working properly. Looping to 4 should give you a list of (6,1). Looping to 8 should give a list of (8,2,1).
5. Once this process is debugged, run it for the full loop overnight. It will take that long no matter how much memory you have. A fast processor will help.
6. 12 largest digits are the last 12 elements of the list, 12 smallest are the first 12.

That is -A- way to do it. I bet there are better, but I have not found one.

I will try to create some code based on your comment. Maybe I'll ask you for help with step three
Reply


Messages In This Thread
RE: how do I show 12 numbers from a huge number? - by anabeatriz - Sep-02-2019, 08:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Random Generator: From Word to Numbers, from Numbers to n possibles Words Yamiyozx 2 1,504 Jan-02-2023, 05:08 PM
Last Post: deanhystad
  Convert list of numbers to string of numbers kam_uk 5 3,095 Nov-21-2020, 03:10 PM
Last Post: deanhystad
  Divide a number - Multiple levels - Sum of all numbers equal to input number pythoneer 17 8,971 Apr-20-2018, 04:07 AM
Last Post: pythoneer
  Trying to get the week number from a string of numbers fad3r 2 3,279 Apr-15-2018, 06:52 PM
Last Post: ljmetzger
  Regular Expressions in Files (find all phone numbers and credit card numbers) Amirsalar 2 4,165 Dec-05-2017, 09:48 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020