#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, long);
int /*<<< orphan*/ scanf(char *, long *);
int main() {
  long t;
  scanf("%ld", &t);
  while (t--) {
    long n;
    scanf("%ld", &n);
    long s = 1, sum = 0;
    while (1) {
      s *= 5;
      if (s > n)
        break;
      else {
        long k = n / s;
        sum += k;
      }
    }
    printf("%ld\n", sum);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     11c8 <main+0xa8>
lea    0xea1(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
movq   $0x1,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
imul   $0x5,-0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jle    1194 <main+0x74>
jmp    11b3 <main+0x93>
mov    -0x18(%rbp),%rax
cqto
idivq  -0x20(%rbp)
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    1178 <main+0x58>
mov    -0x28(%rbp),%rsi
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0x1f>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed0(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
subq   $0x1,(%rsp)
jae    114b <main+0x2b>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xeae(%rip),%r14
lea    0x8(%rsp),%r15
lea    0xea6(%rip),%rbx
jmp    116f <main+0x4f>
mov    %rbx,%rdi
call   1030 <printf@plt>
subq   $0x1,(%rsp)
jb     113f <main+0x1f>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%rcx
mov    $0x5,%edi
mov    $0x0,%esi
cmp    $0x5,%rcx
jge    11b4 <main+0x94>
jmp    1160 <main+0x40>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rcx,%rax
cqto
idiv   %rdi
add    %rax,%rsi
lea    (%rdi,%rdi,4),%rdi
cmp    %rcx,%rdi
jg     1160 <main+0x40>
mov    %rcx,%rax
or     %rdi,%rax
shr    $0x20,%rax
jne    11a0 <main+0x80>
mov    %ecx,%eax
xor    %edx,%edx
div    %edi
jmp    11a8 <main+0x88>

LLVM IR (-O0):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
br label %8
8: ; preds = %29, %0
%9 = load i64, i64* %2
%10 = add nsw i64 %9, -1
store i64 %10, i64* %2
%11 = icmp ne i64 %9, 0
br i1 %11, label %12, label %32
12: ; preds = %8
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %3)
store i64 1, i64* %4
store i64 0, i64* %5
br label %14
14: ; preds = %12, %28
%15 = load i64, i64* %4
%16 = mul nsw i64 %15, 5
store i64 %16, i64* %4
%17 = load i64, i64* %4
%18 = load i64, i64* %3
%19 = icmp sgt i64 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %14
br label %29
21: ; preds = %14
%22 = load i64, i64* %3
%23 = load i64, i64* %4
%24 = sdiv i64 %22, %23
store i64 %24, i64* %6
%25 = load i64, i64* %6
%26 = load i64, i64* %5
%27 = add nsw i64 %26, %25
store i64 %27, i64* %5
br label %28
28: ; preds = %21
br label %14
29: ; preds = %20
%30 = load i64, i64* %5
%31 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %30)
br label %8
32: ; preds = %8
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%5 = load i64, i64* %1
%6 = add nsw i64 %5, -1
store i64 %6, i64* %1
%7 = icmp eq i64 %5, 0
br i1 %7, label %27, label %8
8: ; preds = %0
%9 = bitcast i64* %2 to i8*
br label %10
10: ; preds = %8, %21
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
%12 = load i64, i64* %2
%13 = icmp slt i64 %12, 5
br i1 %13, label %21, label %14
14: ; preds = %10, %14
%15 = phi i64 [ %19, %14 ], [ 5, %10 ]
%16 = phi i64 [ %18, %14 ], [ 0, %10 ]
%17 = sdiv i64 %12, %15
%18 = add nsw i64 %17, %16
%19 = mul nsw i64 %15, 5
%20 = icmp sgt i64 %19, %12
br i1 %20, label %21, label %14
21: ; preds = %14, %10
%22 = phi i64 [ 0, %10 ], [ %18, %14 ]
%23 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %22)
%24 = load i64, i64* %1
%25 = add nsw i64 %24, -1
store i64 %25, i64* %1
%26 = icmp eq i64 %24, 0
br i1 %26, label %27, label %10
27: ; preds = %21, %0
ret i32 0
}