Bottom Page

Thread Rating:
  • 3 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Finding Prime Factors
#1
code must read number from txt.file
a=104

i = 2
while i < a:
    if a % i == 0:
        print(i)
        a /= i
    else:
        i += 1
print(a)
Larz60+ wrote Jan-11-2019, 04:25 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Quote
#2
See Larz's note about tags. I changed the tags to python tags for you. Note that icode tags are only for inline code.

If you need to read from a file, the basic method is text = open(file_name).read().
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Finding Consonants? nlord7 1 103 Feb-28-2019, 03:20 AM
Last Post: ichabod801
  Help with finding vowels nlord7 1 93 Feb-27-2019, 04:40 AM
Last Post: ichabod801
  Finding and storing all string with character A at middle position Pippi 2 148 Jan-20-2019, 08:23 AM
Last Post: Pippi
  Finding Row Number for Items in 2D array fafzal 2 222 Jan-10-2019, 06:11 AM
Last Post: fafzal
  Prime numbers calculations frequency 3 263 Nov-27-2018, 07:07 PM
Last Post: micseydel
  Finding the Young's Modulues in a curve stress strain AicramM 1 247 Nov-03-2018, 09:01 PM
Last Post: Gribouillis
  Program that displays the number with the greatest amount of factors ilusmd 3 291 Nov-01-2018, 08:28 PM
Last Post: ichabod801
  finding the minimum value out of a set of inputs kannan 1 335 Oct-30-2018, 01:52 PM
Last Post: ichabod801
  finding almost palindromes leahma 1 330 Oct-20-2018, 04:14 PM
Last Post: micseydel
  10x10 Array of Prime Numbers smfox2 1 370 Sep-03-2018, 12:36 AM
Last Post: ichabod801

Forum Jump:


Users browsing this thread: 2 Guest(s)