From 5026512bf00b7f341217485075f5f4b78ddb9dc8 Mon Sep 17 00:00:00 2001 From: AmanDeep9925 Date: Thu, 10 Oct 2019 18:12:59 +0530 Subject: [PATCH 1/2] Added question Power_Digit_Sum --- Questions/Power_Digit_Sum.md | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Questions/Power_Digit_Sum.md diff --git a/Questions/Power_Digit_Sum.md b/Questions/Power_Digit_Sum.md new file mode 100644 index 0000000..783366e --- /dev/null +++ b/Questions/Power_Digit_Sum.md @@ -0,0 +1,41 @@ +# Power Digit Sum + +## Problem + +**29 = 512** and the sum of its digits **5+1+2 = 8.** + +What is the sum of the digits of the number 2N? + +### Input Format + +The first line contains an integer _**T**_, i.e., number of test cases. + +Next _T_ lines will contain an integer _**N**_. + +### Constraints + +- 1 ≤ _**T**_ ≤ 100 +- 1 ≤ _**N**_ ≤ 104 + +### Output Format + +Print the values corresponding to each test case. + +### Sample Input + + 3 + 3 + 4 + 7 + +### Sample Output + + 8 + 7 + 11 + +### Expalanation + +- **23**, sum of digits is **8**. +- **24**, sum of digits is **7**. +- **27**, sum of digits is **11**. From cc52695b765644d15e99aba6f13f4b36520bf7d8 Mon Sep 17 00:00:00 2001 From: AmanDeep9925 Date: Tue, 15 Oct 2019 12:21:58 +0530 Subject: [PATCH 2/2] Solution of Even_Fibonacci_Numbers.cpp --- Solutions/Even_Fibonacci_Numbers.cpp | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Solutions/Even_Fibonacci_Numbers.cpp diff --git a/Solutions/Even_Fibonacci_Numbers.cpp b/Solutions/Even_Fibonacci_Numbers.cpp new file mode 100644 index 0000000..996e2eb --- /dev/null +++ b/Solutions/Even_Fibonacci_Numbers.cpp @@ -0,0 +1,38 @@ +// Solution to the Problem Even_Fibonacci_Numbers + +#include +#include +using namespace std; + +int main() +{ + int T; + cin >> T; + + while (T--) + { + int N; + cin >> N; + + vector fib; + + int f0 = 0, f1 = 1, nextTerm = f0 + f1; + while (nextTerm < N) + { + fib.push_back(nextTerm); + f0 = f1; + f1 = nextTerm; + } + + int FibSum = 0; + + for (int i = 0; i < fib.size; ++i) + { + if (fib[i] % 2 == 0) + { + FibSum += fib[i]; + } + } + cout << FibSum << "\n"; + } +} \ No newline at end of file