Question: I want to plot line graph row my row & I want the previous line to be updated by the next line (on the same frame).
Here's the example of the input:

[![enter image description here](https://i.stack.imgur.com/OnJJS.png)](https://i.stack.imgur.com/OnJJS.png)

Here's the code that I have:

```
def openB():
bmFile = filedialog.askopenfile(mode='r',
                                    filetypes=(("CSV file", "*.csv"), ("All files", "*.*")),
                                    title="Select a CSV file")

bmFile2 = pd.read_csv(bmFile, header=[2])

selectCol = bmFile2.iloc[0:,3:]

selectCol.T.plot()
plt.show()

```

I want to plot each row, that's why I am using Transpose method on selectCol.

In order to plot row by row (dynamically changing), what function should I do?
FuncAnimation or for loop (range)?
and How?

Thank you.
Greatly appreciated :)

Answer: 
Check this code you will save a lot of time

Using `sqrt` for optimization

```
from math import sqrt
def Euler3(n):
    x=int(sqrt(n))
    for i in range(2,x+1):
        while n % i == 0:
            n //= i
            if n == 1 or n == i:
                return i
    return n
n = int(input())
print(Euler3(n))

```

---

Also, check my [Euler git repo](https://github.com/7u5h4r/ProjectEuler)

There are only 6 solutions in python2 and it's pretty old but they are very well optimized.
What would be more efficient is to only divide your number by actual primes. You also only need to check divisors up to the square root of the number given that any valid (integer) result will be also be a divisor (which you will already have checked if your divisor goes beyond the square root).

```
# generator to obtain primes up to N
# (sieve of Eratosthenes)

def primes(N):
    isPrime = [True]*(N+1)
    p = 2
    while p<=N:
        if isPrime[p]:
            yield p
            isPrime[p::p] = (False for _ in isPrime[p::p])
        p += 1 + p>2

# use the max function on primes up to the square root 
# filtered to only include those that divide the number

n = 600851475143        
result = max(p for p in primes(int(n**0.5)+1) if n%p == 0)

print(result) # 6857

```

Alternatively, you can use sequential divisions to find factors while reducing the number as you go along. This will cause each new factor you find to be a prime number because divisions by all smaller numbers will already have been done and removed from the remaining number. It will also greatly reduce the number of iterations when your number has many prime factors.

```
def primeFactors(N): # prime factors generator
    d,d2 = 2,4                 # start divisors at first prime (2)
    while d2<=N:               # no need to go beyond √N
        if N%d: 
            d += 1 + (d&1)     # progress by 2 from 3 onward
            d2 = d*d           # use square of d as limiter
        else:
            yield d            # return prime factor
            N //= d            # and reduce number
    if N>1: yield N            # final number could be last factor

print(*primeFactors(600851475143)) # 71 839 1471 6857

print(max(primeFactors(600851475143))) # 6857

```