Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int factorial(int a){
- int fact = 1;
- for(int i=1; i<=a; i++){
- fact *= i;
- }
- return fact;
- }
- int main(){
- int arr[5],count=0,j=0,k,pos_arr[5];
- for(int i = 0; i < 5; i++){
- cin >> arr[i];
- if(arr[i] > 0){
- pos_arr[j] = arr[i];
- j++;
- }
- if(arr[i]%2==0){
- count++;
- }
- }
- cout << "Count of even numbers is: " << count << endl;
- int base = pos_arr[0];
- for(k=0; k< j - 1; k++){
- for(int i=k+1; i<j; i++){
- if(factorial(base*pos_arr[i]) > pow(10,30)){
- cout << "Factorial of " << base*pos_arr[i] << " is valid" << endl;
- }
- }
- base *= pos_arr[k+1];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement