We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Project Euler #42: Coded triangle numbers
Project Euler #42: Coded triangle numbers
Contest ends in
Sort by
recency
|
23 Discussions
|
Please Login in order to post a comment
100% python - uses qudratic formula
Easy solution in Python-3 ''' T = int(input().strip()) for _ in range(T): T_th_n = int(input().strip()) N = ((1 + 8*T_th_n)**0.5-1)/2 if N == int(N): print(int(N)) else: print(-1) '''
Approach:-
The code uses a for loop to iterate over a range of T test cases. For each test case, it takes an input T_th_n and calculates N using a mathematical formula. If N is an integer, it prints the integer value of N. Otherwise, it prints -1. The approach seems to be solving a mathematical problem related to finding the value of N.
Easy solution in Python 3
simple code in c:
int main() {
}
JAva code