Codeforces problem 1350A
Can someone tell me why I am getting a tle error

t = int(input())
for i in range(t):
n , k = list(map(int,input().strip().split()))

def second(a):
    for i in range(2, a + 1):
        if a % i == 0:
            b = i
    return b

for i in range(k):
    c = n
    fn = second(c)
    n = n + fn
    c = n

the value of k ≤ 109
so it will surely give you TLE.
Try using √N approach.

Can you tell me from where can I study these concepts as recently I have started practicing these problems and often encounter such error. Your help will be greatly appreciated.

Just search on internet for the name of the concept, or search in Geeks for Geeks. Take a look at editorials and checkout blogs available in codeforces. There’s no specific portal, or specific set of syllabus to learn.

Have fun learning, and happy coding! :smiley:

Thanks a lot.