- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Find last five digits of a given five digit number raised to power five in C++

In this problem, we are given a number N. Our task is to *find the last five digits of a given five digit number raised to power five. *

**Let’s take an example to understand the problem, **

**Input: **N = 25211

**Output:**

## Solution Approach

To solve the problem, we need to find only the last five digits of the resultant value. So, we will find the last digit of the number after every power increment by finding the 5 digit remainder of the number. At last return the last 5 digits after power of 5.

## Program to illustrate the working of our solution,

## Example

#include <iostream> using namespace std; int lastFiveDigits(int n) { int result = 1; for (int i = 0; i < 5; i++) { result *= n; result %= 100000; } cout<<"The last five digits of "<<n<<" raised to the power 5 are "<<result; } int main() { int n = 12345; lastFiveDigits(n); return 0; }

## Output

The last five digits of 12345 raised to the power 5 are 65625

- Related Questions & Answers
- C program to find sum of digits of a five digit number
- Five Unexpected Uses of Canva
- The Five Stages of a Capital Budgeting Process
- Show android notification every five minutes?
- How to limit records to only the last five results in MySQL
- What is Rule of Five in C++11?
- Rule of Three vs Rule of Five in C++?
- What are the five pillars of NIST Cybersecurity Framework?
- What are the five main sources of electrical energy?
- 8085 Program to check for two out of five code
- Five Signs That You Should Quit Your Job!
- How to make twitter bots in less than five minutes
- Create a MySQL stored procedure that generates five random numbers?
- Program to check for two out of five code in 8085 Microprocessor
- Number of digits in 2 raised to power n in C++

Advertisements