I am working on the Euler problems and found this code online for the third problem.
I used Python 3 to solve the third and fourth problems.
def lpf(c): # largest_prime_factor
i = 2
while i * i <= c:
if c % i:
i += 1
else:
c //= i # c // i returns the integer quotient of c/i
return c
I know that the //
returns the integer quotient of a division, but what is happening when an equal sign is put just after it?
c //= i
--> Is the integer quotient of c/i
affected to the variable c
?
Also, I am working on palindromes for problem 4 and I found this operator ::
.
For example, here is code using it:
> s = str(12321)
> print(s == s[::-1])
Output : True
(If the number is a palindrome, then output is True
, else the output is False
.)
Is the operator ::
reading the string and changing it with an option? If so, how do you use it?