Finding trailing zeroes in factorial

class Solution {
public int trailingZeroes(int n) {

    if(n==0 || n==1)
        return 0;
    
    int[] strg=new int[n+1];
    int c=0;
    //seed
    strg[0]=1;
    strg[1]=1;
   
    for(int i=2;i<=n;i++)
    {
        strg[i]=strg[i-1]*i;
    }
    int x=strg[n];
    
    
    while(x!=0 && x%10==0)
    {
        c++;
        x=x/10;
    }
    return c;
}

}

getting wrong answer after 12. what is wrong in this code?

@Kapsime_S

 bool isSorted(int* a, int n){
    if(n == 1){
        return true;
    }
    //Recursive case
     if(a[0]<=a[1] && isSorted(a+1, n-1)) {
        return true;
    }
    return false;
}

refer to this logic

how is this related to the question? i need to find how zeros many are there at the end in n! . what needs to be sorted?

@Kapsime_S
refer to this

Sorry but I’m not able to understand how to apply sorting algo in the question. Can you tell what is the mistake in my code?