Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions Questions/Power_Digit_Sum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Power Digit Sum

## Problem

**2<sup>9</sup> = 512** and the sum of its digits **5+1+2 = 8.**

What is the sum of the digits of the number 2<sup>N</sup>?

### 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 &#8804; _**T**_ &#8804; 100
- 1 &#8804; _**N**_ &#8804; 10<sup>4</sup>

### Output Format

Print the values corresponding to each test case.

### Sample Input

3
3
4
7

### Sample Output

8
7
11

### Expalanation

- **2<sup>3</sup>**, sum of digits is **8**.
- **2<sup>4</sup>**, sum of digits is **7**.
- **2<sup>7</sup>**, sum of digits is **11**.
38 changes: 38 additions & 0 deletions Solutions/Even_Fibonacci_Numbers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Solution to the Problem Even_Fibonacci_Numbers

#include <iostream>
#include <vector>
using namespace std;

int main()
{
int T;
cin >> T;

while (T--)
{
int N;
cin >> N;

vector<int> 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";
}
}