You are viewing a single comment's thread. Return to all comments →
why is this getting timed out?
import math def checkTriangular(num): return (math.sqrt(8*num+1)-1)%2==0 def checkpentagonal(num): return (math.sqrt(24*num+1)+1)%6==0 def checkhexagonal(num): return (math.sqrt(8*num+1)+1)%4==0 n,a,b=map(int,input().split(" ")) if a==3 and b==5: for i in range(1,n): if checkTriangular(i) and checkpentagonal(i): print(i) else: for i in range(1,n): if checkpentagonal(i)and checkhexagonal(i): print(i)
Project Euler #45: Triangular, pentagonal, and hexagonal
You are viewing a single comment's thread. Return to all comments →
why is this getting timed out?