Can I take two variables a and b, and start traversing from 1 to 2000, and find factors of each number and store number of ‘2’ as factor in ‘a’ and no. of ‘5’ as factor in ‘b’…and lower of a and b will be the trailing zeroes for that particular number that is being traversed.
please check this approach, it has O(2000*2000) complexity