Infinite loop's contest problem ie Zeroes?

problem link, hey please see if i am doing right in this code written in Pascal FPC


program  ZEROES;

uses Math;

var
   T,N,x:integer;
   result:longint;
   
function calculate(num:integer):longint;
begin
	for x := 1 to N do
	begin
		result := result*intpower(x,x);
	end;
	
	calculate := result;
end;
begin
	
	read(T);
	
	while T <> 0 do
	begin
	
	readln(N);
	result := 1;

	writeln(calculate(N));
	T := T-1;
	end;
	
end.

You have to calculate the number of trailing zeroes in the end of the calculated value of f(n).
I think you are calculating only f(n).