Advertisement
Kalhnyxtakias

Untitled

Dec 9th, 2020
801
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int factorial(int a){
  6.     int fact = 1;
  7.     for(int i=1; i<=a; i++){
  8.         fact *= i;
  9.     }
  10.     return fact;
  11. }
  12. int main(){
  13.     int arr[5],count=0,j=0,k,pos_arr[5];
  14.  
  15.     for(int i = 0; i < 5; i++){
  16.         cin >> arr[i];
  17.  
  18.         if(arr[i] > 0){
  19.             pos_arr[j] = arr[i];
  20.             j++;
  21.         }
  22.        
  23.         if(arr[i]%2==0){
  24.             count++;
  25.         }
  26.     }
  27.  
  28.     cout << "Count of even numbers is: " << count << endl;
  29.  
  30.     int base = pos_arr[0];
  31.    
  32.     for(k=0; k< j - 1; k++){
  33.         for(int i=k+1; i<j; i++){
  34.             if(factorial(base*pos_arr[i]) > pow(10,30)){
  35.                 cout << "Factorial of " << base*pos_arr[i] << " is valid" << endl;
  36.             }
  37.         }
  38.         base *= pos_arr[k+1];
  39.     }
  40.    
  41.  
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement