#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 log(int);
scalar_t__ pow(int, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int k;
  int n, j, l;
  scanf("%d", &l);
  for (j = 1; j <= l; j++) {
    scanf("%d", &n);
    k = log(n) / log(5);
    int sum = 0, i;
    for (i = 1; i <= k; i++) {
      sum += n / (int)(pow(5, i));
    }
    printf("%d\n", sum);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1209 <main+0xc9>
lea    0xe87(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%edi
call   1050 <log@plt>
mov    %eax,-0x20(%rbp)
mov    $0x5,%edi
call   1050 <log@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11ec <main+0xac>
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%esi
mov    $0x5,%edi
call   1060 <pow@plt>
mov    %rax,%rcx
mov    -0x24(%rbp),%eax
cltd
idiv   %ecx
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b0 <main+0x70>
mov    -0x18(%rbp),%esi
lea    0xe0d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1166 <main+0x26>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeab(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    128f <main+0x14f>
mov    $0x1,%r13d
lea    0xe89(%rip),%r14
jmp    11a2 <main+0x62>
nopl   0x0(%rax)
xor    %ebp,%ebp
lea    0xe7a(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
lea    0x1(%r13),%eax
cmp    0xc(%rsp),%r13d
mov    %eax,%r13d
jge    128f <main+0x14f>
mov    %r14,%rdi
lea    0x8(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x8(%rsp),%edi
call   1050 <log@plt>
mov    %eax,%ebx
mov    $0x5,%edi
call   1050 <log@plt>
mov    %eax,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
test   %eax,%eax
jle    1180 <main+0x40>
mov    %eax,%r12d
cmp    $0x1,%eax
jne    11f0 <main+0xb0>
xor    %ebp,%ebp
mov    $0x1,%r15d
test   $0x1,%r12b
je     1182 <main+0x42>
jmp    126f <main+0x12f>
nopw   0x0(%rax,%rax,1)
mov    %r13,0x10(%rsp)
mov    %r12d,%r13d
and    $0xfffffffe,%r13d
xor    %ebp,%ebp
mov    $0x1,%r15d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x8(%rsp),%r14d
mov    $0x5,%edi
mov    %r15d,%esi
call   1060 <pow@plt>
mov    %rax,%rcx
mov    %r14d,%eax
cltd
idiv   %ecx
mov    %eax,%ebx
add    %ebp,%ebx
mov    0x8(%rsp),%ebp
lea    0x1(%r15),%r14d
mov    $0x5,%edi
mov    %r14d,%esi
call   1060 <pow@plt>
mov    %rax,%rcx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %eax,%ebp
add    %ebx,%ebp
add    $0x2,%r15d
cmp    %r13d,%r14d
jne    1210 <main+0xd0>
lea    0xda0(%rip),%r14
mov    0x10(%rsp),%r13
test   $0x1,%r12b
je     1182 <main+0x42>
mov    0x8(%rsp),%ebx
mov    $0x5,%edi
mov    %r15d,%esi
call   1060 <pow@plt>
mov    %rax,%rcx
mov    %ebx,%eax
cltd
idiv   %ecx
add    %eax,%ebp
jmp    1182 <main+0x42>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 1
br i1 %7, label %56, label %8
8: ; preds = %0, %50
%9 = phi i32 [ %53, %50 ], [ 1, %0 ]
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = call i32 @log(i32 %11)
%13 = call i32 @log(i32 5)
%14 = sdiv i32 %12, %13
%15 = icmp slt i32 %14, 1
br i1 %15, label %50, label %16
16: ; preds = %8
%17 = and i32 %14, 1
%18 = icmp eq i32 %14, 1
br i1 %18, label %39, label %19
19: ; preds = %16
%20 = and i32 %14, -2
br label %21
21: ; preds = %21, %19
%22 = phi i32 [ 1, %19 ], [ %36, %21 ]
%23 = phi i32 [ 0, %19 ], [ %35, %21 ]
%24 = phi i32 [ 0, %19 ], [ %37, %21 ]
%25 = load i32, i32* %1
%26 = call i64 @pow(i32 5, i32 %22)
%27 = trunc i64 %26 to i32
%28 = sdiv i32 %25, %27
%29 = add nsw i32 %28, %23
%30 = add nuw i32 %22, 1
%31 = load i32, i32* %1
%32 = call i64 @pow(i32 5, i32 %30)
%33 = trunc i64 %32 to i32
%34 = sdiv i32 %31, %33
%35 = add nsw i32 %34, %29
%36 = add nuw i32 %22, 2
%37 = add i32 %24, 2
%38 = icmp eq i32 %37, %20
br i1 %38, label %39, label %21
39: ; preds = %21, %16
%40 = phi i32 [ undef, %16 ], [ %35, %21 ]
%41 = phi i32 [ 1, %16 ], [ %36, %21 ]
%42 = phi i32 [ 0, %16 ], [ %35, %21 ]
%43 = icmp eq i32 %17, 0
br i1 %43, label %50, label %44
44: ; preds = %39
%45 = load i32, i32* %1
%46 = call i64 @pow(i32 5, i32 %41)
%47 = trunc i64 %46 to i32
%48 = sdiv i32 %45, %47
%49 = add nsw i32 %48, %42
br label %50
50: ; preds = %44, %39, %8
%51 = phi i32 [ 0, %8 ], [ %40, %39 ], [ %49, %44 ]
%52 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %51)
%53 = add nuw nsw i32 %9, 1
%54 = load i32, i32* %2
%55 = icmp slt i32 %9, %54
br i1 %55, label %8, label %56
56: ; preds = %50, %0
ret i32 0
}