From ae751f4ce89ffe2f249b6084f0097d7f089600c3 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Date: Thu, 1 Oct 2020 21:08:27 +0530 Subject: [PATCH] Create #1.cpp --- Project Euler - HackerRank/#1.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Project Euler - HackerRank/#1.cpp diff --git a/Project Euler - HackerRank/#1.cpp b/Project Euler - HackerRank/#1.cpp new file mode 100644 index 000000000..5e038fda9 --- /dev/null +++ b/Project Euler - HackerRank/#1.cpp @@ -0,0 +1,11 @@ + +t=int(input()) +def ar(x): + return x*(x+1); +for i in range(t): + n =int(input()) + n -=1; + a=int(n/3); + b=int(n/5); + c=int(n/15); + print(int(int(3*ar(a) + 5*ar(b) - 15*ar(c))>>1));