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 and storing all string with character A at middle position Pippi 2 65 Jan-20-2019, 08:23 AM
Last Post: Pippi
  Finding Row Number for Items in 2D array fafzal 2 144 Jan-10-2019, 06:11 AM
Last Post: fafzal
  Prime numbers calculations frequency 3 181 Nov-27-2018, 07:07 PM
Last Post: micseydel
  Finding the Young's Modulues in a curve stress strain AicramM 1 171 Nov-03-2018, 09:01 PM
Last Post: Gribouillis
  Program that displays the number with the greatest amount of factors ilusmd 3 206 Nov-01-2018, 08:28 PM
Last Post: ichabod801
  finding the minimum value out of a set of inputs kannan 1 198 Oct-30-2018, 01:52 PM
Last Post: ichabod801
  finding almost palindromes leahma 1 208 Oct-20-2018, 04:14 PM
Last Post: micseydel
  10x10 Array of Prime Numbers smfox2 1 307 Sep-03-2018, 12:36 AM
Last Post: ichabod801
  calculate the 10001st prime number topologh 3 758 Mar-30-2018, 07:04 PM
Last Post: Zatox11
  Finding the average of numbers in a txt file piday 1 1,956 Feb-27-2018, 04:00 AM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)