RTE in Easy Math

Problem link:https://www.codechef.com/problems/RPD
Problem code:RPD
In my code it is showing runtime error SIGPFE

#include <iostream>
#include<algorithm>
using namespace std;
int fact(int n){

     return (n==0) || (n==1) ? 1 : n* fact(n-1);
}
int combination(int n)
{
    int d=fact(n)/(fact(n-2)*2);
    return d;
}
void sumer(int arr[],int n,int def[])
{
    
    for(int i=0;i<n;i++)
    {
        while(arr[i]>0)
        {
        def[i]+=arr[i]%10;
        arr[i]=arr[i]/10;
        }
    }
}

int main() {
 int t,n;
 cin>>t;
 
 
 while(t-- )
 {
      cin>>n;
     int ar[n];
     for(int i=0;i<n;i++)cin>>ar[i];
     int f=combination(n);
    int def[f];
    int final[f]={0};
    int p=0;
    for(int i=0;i<n-1;i++)
    {
     for(int j=i+1;j<n;j++)
     {
         def[p]=ar[i]*ar[j];
         p++;
      }
     }
     sumer(def,f,final);
     sort(final,final+f);
     cout<<final[f-1]<<endl;
 }
	return 0;
}

anyone pls @sebastian

Consider the test input:

1                                                                      
34
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
3 Likes

i got it … i need to make function of factorial with large number…thnks @ssjgz

1 Like