-1

As val is large.So it is not executing code.What can we do to solve this problem.

val = 78478277380 
i = 2
while i < val:
   if val % i == 0:
       print(i)
   i += 1

I want all factors of the val.

  • 1
    What do you mean by "it is not executing code" ? What happens? Any errors? – Ralf Apr 04 '19 at 15:09
  • The number doesn't have too many factors? – Nishant Apr 04 '19 at 15:10
  • Take a look at [this question](https://stackoverflow.com/questions/6800193/what-is-the-most-efficient-way-of-finding-all-the-factors-of-a-number-in-python) for other solutions to the same problem – Ralf Apr 04 '19 at 15:19

2 Answers2

0

Running this on my machine, I get the first 5 factors: 2, 4, 5, 10, 20 and then it goes quiet for a while. This is not because it stopped running, but because I'm pretty sure the next factor is 3923913869 which will take a while to find. Source.

Andrew F
  • 2,690
  • 1
  • 14
  • 25
0

If you print the all the numbers, you will get a better idea of what is happening:

val = 78478277380
i = 2
while i < val:
   print(str(i) + "is a not factor")
   if val % i == 0:
       print(str(i) + "is a factor")
   i += 1

The problem is that there aren't too many factors for this number.

Nishant
  • 20,354
  • 18
  • 69
  • 101