C++ Sum of Fibonacci Numbers at Even Indexes up to N Terms

Computing the sum of Fibonacci numbers at even indexes up to N terms is an intriguing variation on generating the Fibonacci sequence. The Fibonacci sequence starts with 0, 1, 1, 2, 3, 5, 8, 13, 21,…… where each number is the sum of the two preceding ones. When asked to sum the numbers at even indexes, we’re looking at positions 0,2, 4, 6,… in the sequence, keeping in mind that indexing starts from 0.

Before delving into the specifics of writing a C++ program to solve this problem, it’s crucial to understand the approach and the logic behind the algorithm. This task combines understanding the Fibonacci sequence, iterating through the sequence efficiently, and aggregating the values at even positions.

Understanding the Problem

In the Fibonacci sequence:

  • The 0th term is 0, the 1st term is 1, and every subsequent term is the sum of the previous two.
  • An even index implies positions like 0,2,4,6… in the sequence.

Our goal is to calculate the sum of the Fibonacci numbers located at these even indexes up to N terms in the sequence.

Efficient Approach

An efficient approach avoids calculating the entire sequence up to N terms or using separate storage for the sequence. Since only even-indexed terms are of interest, we focus on generating and summing these terms directly.

Implementation in C++

Let’s write a C++ program that accomplishes this task, keeping efficiency in mind:

#include <iostream>

using namespace std;

// Function to calculate the sum of Fibonacci numbers at even indexes up to N terms

long long sumEvenFibonacci(int N) {

    if (N <= 0) return 0;

    if (N == 1) return 0; // The 0th Fibonacci number is 0

    if (N == 2) return 1; // Only the 0th and 1st Fibonacci numbers are considered, sum is still 0

    // Starting with the first two terms of the Fibonacci sequence

    long long previous = 0, current = 1, sum = 0;

    // Since we start counting from 0, the 2nd term is at an even index and is the first to be added

    for (int i = 2; i < N; i += 2) {

        // Calculate the next Fibonacci number

        long long next = previous + current;

        // Update the previous two terms for the next iteration

        previous = current;

        current = next;

        // Calculate the next Fibonacci number (to reach the next even index)

        next = previous + current;

        // Summing up the Fibonacci numbers at even indexes

        sum += next;

        // Update the previous and current terms to the next values for subsequent iterations

        previous = current;

        current = next;

    }

    return sum;

}

int main() {

    int N;

    cout << “Enter the number of terms: “;

    cin >> N;

    cout << “Sum of Fibonacci numbers at even indexes up to ” << N << ” terms is: ” << sumEvenFibonacci(N) << endl;

    return 0;

}

 

Explanation

  • Base Cases:

The function sumEvenFibonacci initially handles base cases where N is 0, 1, or 2, returning 0 since either there are no even-index terms or the only such term doesn’t contribute to the sum.

  • Fibonacci Sequence Generation and Summation:

The core of the function lies in iterating through the Fibonacci sequence, focusing on even-index terms. Since the even-index terms are every other term in the sequence, we calculate two steps in each iteration of the loop: first to get to the next term (which is odd-indexed and thus not added to the sum) and a second time to reach the next even-indexed term, which is added to the sum.

  • Optimization:

The loop iterates in steps of 2, effectively skipping the calculation of the odd-indexed terms’ contribution to the sum. This approach directly calculates and sums the even-indexed Fibonacci numbers without explicitly checking if an index is even.

C++ Program to Reverse a Number

Reversing a number in C++ is a task that exemplifies a broad spectrum of programming concepts, including loops, modular arithmetic, and dealing with numeric data types. This operation involves taking a numerical input and producing a new number that has its digits in reverse order. For example, reversing 1234 yields 4321. The process of writing a C++ program to reverse a number not only illuminates basic programming constructs but also encourages thinking about how numbers are stored and manipulated computationally.

Understanding the Problem

At first glance, reversing a number might seem straightforward. However, it involves careful consideration of how to deconstruct a number into its constituent digits and then reassemble those digits in reverse order. This task can enhance one’s understanding of loops, integer division, and modulo operations in C++.

Initial Setup

Every C++ program starts with setting up the necessary environment, which includes incorporating header files and using the standard namespace to simplify syntax.

#include <iostream>

using namespace std;

These lines of code prepare the program for input/output operations, a fundamental aspect of interacting with the user.

Soliciting User Input

An interactive program should prompt the user for input. In this case, we need a number to reverse:

int main() {

    long long n; // Using long long for a wider range of input

    cout << “Enter a number to reverse: “;

    cin >> n;

This snippet gathers a number from the user, storing it in a variable n. The choice of long long for the variable type allows the program to handle a larger range of numbers, making it more robust.

The Reversal Logic

The core of the program lies in reversing the given number. This process involves iteratively extracting the last digit of the number and appending it to a new number, which is initially zero. The extraction of digits is done using modulo and division operations:

    long long reversedNumber = 0;

    while(n != 0) {

        int digit = n % 10; // Extract the last digit

        reversedNumber = reversedNumber * 10 + digit; // Append the digit

        n /= 10; // Remove the last digit from n

    }

Here, the modulo operation (n % 10) extracts the last digit, while dividing n by 10 (n /= 10) effectively removes that digit from n. The reversedNumber is built by multiplying the current reversedNumber by 10 (shifting digits to the left) and adding the extracted digit.

Displaying the Result

After reversing the number, the next step is to show the result to the user:

    cout << “Reversed Number: ” << reversedNumber << endl;

    return 0;

}

This part of the program outputs the reversed number, providing immediate feedback to the user.

Handling Edge Cases

While the above code effectively reverses a number, thoughtful programming also involves considering and handling potential edge cases. One common issue is handling negative numbers. The simplest approach is to modify the program to reject negative input or to convert the number to positive before reversing it and then reapplying the sign to the result.

Another consideration is handling leading zeros in the reversed number, which naturally disappear in the integer representation (e.g., reversing 100 yields 1, not 001). This behavior is typically acceptable but should be communicated to the user if necessary.

C++ Program to Make a Simple Calculator

Creating a Simple Calculator in C++ involves handling basic arithmetic operations like addition, subtraction, multiplication, and division. This calculator will take an operation selection input from the user, prompt for two numbers, perform the selected operation, and display the result. To make the calculator user-friendly, we can use a loop that allows users to perform multiple calculations without restarting the program.

Here’s a simple implementation of such a calculator:

#include <iostream>

using namespace std;

int main() {

    char operation;

    double num1, num2;

    // Loop to allow multiple operations

    while (true) {

        cout << “Enter an operation (+, -, *, /) or Q to quit: “;

        cin >> operation;

        if (operation == ‘Q’ || operation == ‘q’) {

            cout << “Calculator exited.” << endl;

            break;

        }

        cout << “Enter the first number: “;

        cin >> num1;

        cout << “Enter the second number: “;

        cin >> num2;

        switch (operation) {

            case ‘+’:

                cout << num1 << ” + ” << num2 << ” = ” << num1 + num2 << endl;

                break;

            case ‘-‘:

                cout << num1 << ” – ” << num2 << ” = ” << num1 – num2 << endl;

                break;

            case ‘*’:

                cout << num1 << ” * ” << num2 << ” = ” << num1 * num2 << endl;

                break;

            case ‘/’:

                if (num2 != 0.0)

                    cout << num1 << ” / ” << num2 << ” = ” << num1 / num2 << endl;

                else

                    cout << “Division by zero error!” << endl;

                break;

            default:

                cout << “Invalid operation!” << endl;

        }

    }

    return 0;

}

This program starts with a loop that continuously prompts the user to enter an operation. If the user inputs ‘Q’ or ‘q’, the program exits. For any other operation, it asks for two numbers. Using a switch statement, it then performs the operation corresponding to the user’s choice. After displaying the result, the loop restarts, allowing another operation to be selected and performed without restarting the program.

Key Features of This Program:

  • Modularity and Readability:

The use of a switch statement makes it easy to understand and modify the code to add more operations if needed.

  • Error Handling for Division:

There’s a check to prevent division by zero, which is a common runtime error in division operations.

  • Loop for Continuous Operation:

The loop allows the calculator to be used multiple times without needing to be restarted, enhancing user experience.

  • User Input Validation:

The program includes a basic form of user input validation for the operation. It ensures that if an invalid operation is entered, an error message is displayed, and no unnecessary calculations are attempted.

C++ Program to For Fibonacci Number

Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, usually starting with 0 and 1. That is, the sequence goes 0, 1, 1, 2, 3, 5, 8, 13, 21, and so on. Writing a C++ program to find the nth Fibonacci number involves understanding the iterative or recursive approach to generate the sequence.

Iterative Approach

The iterative method is more efficient than the recursive one, especially for large numbers, because it doesn’t involve deep function call stacks and thus avoids potential stack overflow issues and excessive memory use.

#include <iostream>

using namespace std;

int fibonacciIterative(int n) {

    if (n <= 1) {

        return n;

    }

    int previous = 0, current = 1;

    for (int i = 2; i <= n; i++) {

        int next = previous + current;

        previous = current;

        current = next;

    }

    return current;

}

int main() {

    int n;

    cout << “Enter the value of n: “;

    cin >> n;

    cout << “The ” << n << “th Fibonacci number (iterative) is: ” << fibonacciIterative(n) << endl;

    return 0;

}

 

Recursive Approach

The recursive method is a straightforward implementation of the Fibonacci definition but can be less efficient due to repeated calculations and deep recursion for large n. It’s a good demonstration of the concept of recursion, though.

#include <iostream>

using namespace std;

int fibonacciRecursive(int n) {

    if (n <= 1) {

        return n;

    } else {

        return fibonacciRecursive(n-1) + fibonacciRecursive(n-2);

    }

}

int main() {

    int n;

    cout << “Enter the value of n: “;

    cin >> n;

    cout << “The ” << n << “th Fibonacci number (recursive) is: ” << fibonacciRecursive(n) << endl;

    return 0;

}

 

Explanation

  • Iterative Approach:

This method initializes the first two Fibonacci numbers, 0 and 1, and iteratively computes the next numbers in the sequence by summing the last two numbers until the nth number is found.

  • Recursive Approach:

This method applies the Fibonacci series definition directly by using a function that calls itself to calculate the sum of the two preceding numbers until the base cases (n = 0 or n = 1) are reached.

Choosing Between Iterative and Recursive

  • Efficiency:

The iterative approach is more efficient and is generally preferred for computing Fibonacci numbers, especially as n gets large.

  • Educational Value:

The recursive approach is often used for educational purposes, to illustrate recursion, despite its inefficiency for larger n due to repeated computations and risk of stack overflow.

C++ Program to Find LCM

Least Common Multiple (LCM) of two integers is the smallest positive integer that is divisible by both. Unlike the Greatest Common Divisor (GCD), which focuses on division without remainders, the LCM is about finding a common multiple, highlighting a complementary aspect of number theory in computer science and programming.

In C++, calculating the LCM efficiently often involves first finding the GCD, due to the mathematical relationship between them: LCM(a, b) = |a * b| / GCD(a, b) for any two integers a and b, where |a * b| denotes the absolute product of a and b. This relationship allows us to leverage the Euclidean algorithm for GCD calculation as a stepping stone to finding the LCM, demonstrating an elegant interplay between these fundamental concepts.

Implementing the LCM Algorithm in C++

The program below implements a function to find the GCD using the Euclidean algorithm, and then uses this function to calculate the LCM of two numbers. This approach not only showcases the efficiency of utilizing existing algorithms but also emphasizes the importance of building complex functionality from simpler, well-understood operations.

#include <iostream>

using namespace std;

// Function to find the GCD of two integers using the Euclidean algorithm

int gcd(int a, int b) {

    while (b != 0) {

        int remainder = a % b;

        a = b;

        b = remainder;

    }

    return a; // When b is 0, a is the GCD

}

// Function to find the LCM of two integers based on the GCD

int lcm(int a, int b) {

    return (a / gcd(a, b)) * b; // Using the relationship LCM(a, b) = (a * b) / GCD(a, b)

}

int main() {

    int num1, num2;

    // Prompt the user to enter two numbers

    cout << “Enter two integers: “;

    cin >> num1 >> num2;

    // Calculate and display the LCM

    cout << “The LCM of ” << num1 << ” and ” << num2 << ” is ” << lcm(num1, num2) << “.” << endl;

    return 0;

}

 

Detailed Explanation

  • GCD Calculation:

The program first defines a function, gcd, that calculates the Greatest Common Divisor of two numbers using the Euclidean algorithm. This function iteratively reduces the pair of numbers until one of them becomes zero, at which point the other number is the GCD.

  • LCM Calculation:

The lcm function then calculates the Least Common Multiple using the formula LCM(a, b) = (a * b) / GCD(a, b). This formula ensures that we find the smallest positive integer divisible by both a and b, by dividing their absolute product by their GCD. The gcd function is called within the lcm function, showcasing the utility of modular, reusable code.

  • Main Program Flow:

The main function prompts the user for two integers, then calculates and displays their LCM using the lcm function. This demonstrates how to interact with the user, perform calculations using custom functions, and display results.

C++ Program to Find GCD

Finding the Greatest Common Divisor (GCD) of two numbers is a fundamental problem in mathematics and computer science, often introduced early in programming courses to illustrate algorithms, loops, and decision-making processes. The GCD of two numbers is the largest positive integer that divides both numbers without leaving a remainder. For example, the GCD of 8 and 12 is 4.

In programming, there are several ways to calculate the GCD, with the Euclidean algorithm being one of the most efficient and commonly used methods. This algorithm is based on the principle that the GCD of two numbers also divides their difference. In C++, implementing the Euclidean algorithm to find the GCD of two numbers can be both a straightforward and insightful exercise.

Introduction to the Euclidean Algorithm

The Euclidean algorithm iteratively reduces the problem of finding the GCD of two numbers until it reaches a case where the GCD is apparent. The algorithm is based on two key observations:

  1. GCD(a, b) = GCD(b, a % b): The GCD of two numbers a and b is the same as the GCD of b and the remainder of a divided by b.
  2. GCD(a, 0) = a: The GCD of any number a and 0 is a.

These properties allow us to repeatedly apply the operation a % b (find the remainder of a divided by b) and swap the numbers until one of them becomes zero. The other number, at that point, is the GCD.

Implementing the GCD Algorithm in C++

Here is a simple implementation of the Euclidean algorithm in C++ to find the GCD of two numbers:

#include <iostream>

using namespace std;

// Function to find the GCD of two integers using the Euclidean algorithm

int gcd(int a, int b) {

    while(b != 0) {

        int remainder = a % b;

        a = b;

        b = remainder;

    }

    return a; // When b is 0, a is the GCD

}

int main() {

    int num1, num2;

    // Prompt the user to enter two numbers

    cout << “Enter two integers: “;

    cin >> num1 >> num2;

    // Ensure the numbers are positive

    if(num1 < 0 || num2 < 0) {

        cout << “Please enter positive integers.” << endl;

        return 1;

    }

    // Calculate and display the GCD

    cout << “The GCD of ” << num1 << ” and ” << num2 << ” is ” << gcd(num1, num2) << “.” << endl;

    return 0;

}

 

Explanation of the Program

  • Input:

The program begins by asking the user to input two integers. These numbers are the ones for which we want to find the GCD.

  • Validation:

It’s a good practice to validate user input. Here, we ensure that the inputs are positive integers, as the GCD concept applies to positive numbers.

  • GCD Calculation:

The gcd function implements the core logic of the Euclidean algorithm. It repeatedly applies the modulo operation to reduce the problem size until one of the numbers becomes zero. The other number, at this point, is the GCD.

  • Output:

Finally, the program outputs the GCD of the two input numbers.

C++ Program to Find Factorial of a Number

Calculating the factorial of a number is a common programming challenge that highlights several key concepts in computer science and software development, including recursion, loops, and handling user input. The factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For instance, 5! = 5×4×3×2×1 = 120.

Introduction to Factorial Calculation

The factorial operation is foundational in combinatorics, probability, and many areas of mathematics and computer science. Its calculation through programming serves not only as a practice in implementing mathematical formulas but also in choosing the appropriate algorithms and structures for a given problem. C++ offers various means to tackle factorial calculation, each with its advantages and considerations.

Setting Up a Basic C++ Program

A C++ program begins with including necessary libraries and using directives:

#include <iostream>

#include <limits>

using namespace std;

Here, iostream is included for input and output operations, and limits might be used for handling data type limits effectively.

Soliciting User Input

Engaging the user and obtaining the number for which to calculate the factorial is the first step:

int main() {

    unsigned int n;

    cout << “Enter a non-negative integer: “;

    cin >> n;

    if(cin.fail() || n > 12) { // Simple validation to prevent overflow in our example

        cout << “Invalid input. Please enter a non-negative integer less than or equal to 12.” << endl;

        return 1; // Exit the program indicating failure

    }

The above code block includes a simple validation check to ensure the input is within a range that prevents overflow for the chosen data type (unsigned int). This is crucial for maintaining the program’s robustness and correctness.

Implementing Factorial Calculation

  • Loop-Based Approach

One way to calculate the factorial of a number is by using a loop. This method iterates from 1 to n, multiplying each number by a running total:

    unsigned long long factorial = 1; // Initialize to 1 as we are multiplying

    for(unsigned int i = 2; i <= n; ++i) {

        factorial *= i;

    }

    cout << n << “! = ” << factorial << endl;

This loop-based method is straightforward and illustrates the iterative approach to solving problems.

  • Recursive Approach

Alternatively, factorial calculation lends itself well to a recursive solution, where a function calls itself with a simpler version of the original problem:

unsigned long long factorial(unsigned int n) {

    if (n <= 1) return 1; // Base case

    else return n * factorial(n – 1); // Recursive case

}

To integrate this into our program, we would modify the main function to call factorial(n) and display the result.

Analyzing the Approaches

Both iterative and recursive approaches have their merits. The iterative solution is straightforward, easy to understand, and efficient in terms of memory usage since it avoids the overhead of multiple function calls. On the other hand, the recursive solution offers a cleaner, more elegant code that closely mirrors the mathematical definition of factorial. However, recursion requires additional memory for each function call’s context, and excessive recursion can lead to stack overflow errors in languages like C++ that do not optimize for tail recursion.

Handling Large Numbers and Efficiency

Calculating factorials for even moderately large numbers quickly results in values that exceed the storage capacity of standard integer types in C++. This limitation highlights the importance of considering data types and potential overflow issues in algorithmic design and implementation. For larger numbers, one might consider using libraries designed for arbitrary-precision arithmetic, though this introduces additional complexity and potential performance considerations.

C++ Program to Display Prime Numbers Between Two Intervals

Prime Numbers are fundamental elements in mathematics and computer science, representing numbers greater than 1 that have no divisors other than 1 and themselves. The task of identifying prime numbers between two intervals highlights key programming concepts such as loops, conditionals, and functions, and is an excellent example of applying computational thinking to solve mathematical problems.

  • Understanding the Task

Displaying prime numbers between two intervals involves iterating through all the numbers in the specified range and checking each number to determine if it is prime. This task is computationally intensive, especially for large intervals, due to the nature of prime number determination. Hence, optimizing the prime check process is crucial to improving the program’s efficiency.

Optimized Approach to Prime Checking

The standard approach to check if a number is prime involves dividing the number by all smaller numbers up to 2. This method can be optimized by observing that:

  1. No prime number is divisible by any number greater than its square root.
  2. Numbers less than 2 are not prime.

Based on these observations, the prime checking function can significantly reduce the number of iterations, enhancing performance.

Implementing the Program

The program will consist of two parts:

  1. A function to check if a number is prime.
  2. The main function that iterates through the range, uses the prime-checking function, and displays the primes.

C++ Program to Display Prime Numbers Between Two Intervals

#include <iostream>

#include <cmath> // For the sqrt() function

using namespace std;

// Function to check if a number is prime

bool isPrime(int num) {

    if (num < 2) return false; // Numbers less than 2 are not prime

    for (int i = 2; i <= sqrt(num); ++i) {

        if (num % i == 0) return false; // If divisible, not prime

    }

    return true; // Number is prime

}

int main() {

    int start, end;

    // Prompt the user for the interval

    cout << “Enter two numbers (intervals): “;

    cin >> start >> end;

    cout << “Prime numbers between ” << start << ” and ” << end << ” are: ” << endl;

    // Iterate through the range and display prime numbers

    for (int num = start; num <= end; ++num) {

        if (isPrime(num)) {

            cout << num << ” “;

        }

    }

    return 0;

}

 

Program Explanation

  • Prime Checking Function (isPrime):

This function takes an integer as input and returns true if the number is prime, otherwise false. It efficiently checks divisibility only up to the square root of the number, leveraging the mathematical insight that factors of a number are always found in pairs, one less than and one greater than the square root of the number.

  • Main Function:

The main function begins by asking the user to input two numbers, defining the interval within which to find prime numbers. It then iterates through each number in this interval, using the isPrime function to check for primality. Prime numbers are displayed to the user.

  • Efficiency and Optimization:

The program is optimized for efficiency by reducing the number of divisions needed to determine if a number is prime. This is critical for larger numbers and wider ranges, where naive approaches might lead to significantly longer computation times.

C++ Program to Display Factors of a Natural Number

Displaying the factors of a natural number involves finding all the numbers that divide the given number without leaving a remainder. Factors are integral to various mathematical calculations and are particularly interesting when exploring number theory, prime numbers, and algorithms that involve divisibility.

In this context, a factor of a number n is any integer i where n % i == 0. To find all such numbers, a straightforward approach involves iterating through all integers from 1 to n and checking if n % i == 0. If the condition holds true, i is a factor of n.

Let’s write a C++ program that takes a natural number as input from the user and displays all its factors:

#include <iostream>

using namespace std;

// Function to print the factors of a given number n

void printFactors(int n) {

    cout << “The factors of ” << n << ” are: “;

    for (int i = 1; i <= n; ++i) {

        if (n % i == 0) {

            cout << i << ” “;

        }

    }

    cout << endl;

}

int main() {

    int number;

    cout << “Enter a natural number: “;

    cin >> number;

    // Check for natural number input

    if (number < 1) {

        cout << “Please enter a natural number greater than 0.” << endl;

    } else {

        printFactors(number);

    }

    return 0;

}

This program begins by prompting the user to enter a natural number. It checks whether the input is a natural number (i.e., an integer greater than 0). If the check passes, the program proceeds to find and print all the factors of the input number using the printFactors function.

Within printFactors, the program iterates from 1 to n, inclusive. For each number i in this range, it checks if n % i == 0. If the condition is true, it means i is a divisor (or factor) of n, and the program prints i.

This method is simple and effective for small to moderately sized integers. However, for very large numbers, more efficient algorithms may be necessary to reduce computational time, such as only checking up to the square root of n and adding both the divisor and the quotient when applicable.

C++ Program to Display Armstrong Numbers Between 1 to 1000

Displaying Armstrong numbers within a specific range, such as from 1 to 1000, is a common programming task that showcases the application of loops, conditionals, and arithmetic operations in C++. Armstrong numbers, as previously discussed, are numbers that equal the sum of their own digits each raised to the power of the number of digits in the number. This property makes them particularly interesting from both mathematical and programming perspectives.

To create a program that identifies and displays Armstrong numbers within a given range, the steps are as follows:

  1. Loop through the Range:

Iterate over each number in the specified range (1 to 1000 in this case).

  1. Check for Armstrong Number:

For each number, determine if it is an Armstrong number.

  1. Display the Number:

If a number is identified as an Armstrong number, display it.

This process requires a function to check if a given number is an Armstrong number, similar to what was outlined previously.

C++ Program

 

#include <iostream>

#include <cmath>

using namespace std;

// Function to calculate the number of digits in a number

int countDigits(int n) {

    int count = 0;

    while (n != 0) {

        count++;

        n /= 10;

    }

    return count;

}

// Function to check if a number is an Armstrong number

bool isArmstrong(int num) {

    int originalNum = num;

    int numOfDigits = countDigits(num);

    int sumOfPowers = 0;

    while (num != 0) {

        int digit = num % 10;

        sumOfPowers += pow(digit, numOfDigits);

        num /= 10;

    }

    return sumOfPowers == originalNum;

}

int main() {

    cout << “Armstrong numbers between 1 to 1000 are:” << endl;

    for (int num = 1; num <= 1000; num++) {

        if (isArmstrong(num)) {

            cout << num << endl;

        }

    }

    return 0;

}

 

Explanation

  1. Counting Digits (countDigits function):

This function, as before, calculates the number of digits in a given number. This is crucial for determining the power to which each digit should be raised.

  1. Armstrong Number Check (isArmstrong function):

This function determines if a given number is an Armstrong number by comparing it to the sum of its digits each raised to the power of the number of digits in the number.

  1. Main Logic:

The main function iterates through numbers from 1 to 1000, utilizing the isArmstrong function to check for Armstrong numbers. When an Armstrong number is found, it is printed out.

error: Content is protected !!