New answers tagged

-2

def prime(n): for i in range(2,(n//2)+1): if n%i==0: return False return True def factor_pair(n): arr=[] for i in range(2,int(math.sqrt(n))+1): if n%i==0: arr.append((i,n//i)) return arr[-1] def downToZero(n): count=2 while(n>2): if prime(n)==True: n=n-1 ...


6

For a coding contest, the answer is almost never to implement the problem the same way as it is given. For example here, functions A and B are actually intentionally misleading. Function A is also known as Euler's Totient, and function B computes the sum of totients of divisors which is the same as the original number. Detailed review of them is therefore a ...


3

You've created an unnecessary scope by putting braces after int querylength. Do you have a good reason for doing this?


Top 50 recent answers are included