### The problem

How many zeroes are at the **end** of the [factorial](https://en.wikipedia.org/wiki/Factorial) of `10`? 10! = 3628800, i.e. there are `2` zeroes.
16! (or 0x10!) in [hexadecimal](https://en.wikipedia.org/wiki/Hexadecimal) would be 0x130777758000, which has `3` zeroes.

### Scalability

Unfortunately, machine integer numbers has not enough precision for larger values. Floating point numbers drop the tail we need. We can fall back to arbitrary-precision ones - built-ins or from a library, but calculating the full product isn't an efficient way to find just the _tail_ of a factorial. Calculating `100'000!` in compiled language takes around 10 seconds. `1'000'000!` would be around 10 minutes, even using efficient [Karatsuba algorithm](https://en.wikipedia.org/wiki/Karatsuba_algorithm)

### Your task

is to write a function, which will find the number of zeroes at the end of `(number)` factorial in arbitrary [radix](https://en.wikipedia.org/wiki/Radix) = `base` for larger numbers.

- `base` is an integer from 2 to 256
- `number` is an integer from 1 to 1'000'000

**Note** Second argument: number is always declared, passed and displayed as a regular _decimal_ number. If you see a test described as `42! in base 20` it's 4210 **not** 4220 = 8210.

Difficulty: interview

Starter code:

def zeroes (base, number):
	

Solutions:
def zeroes (base, number):
    pzeros = []
    for p in range(2, base+1):
        e = 0
        while base % p == 0:
            base /= p
            e += 1
        if e:
            f, m = 0, number
            while m:
                m /= p
                f += m
            pzeros.append(f / e)
    return min(pzeros)

from collections import Counter

def factorize(n):
    f = []
    for i in range(2, n + 1):
        while n % i == 0:
            f.append(i)
            n /= i
    return Counter(f)

def zeroes (base, number):
    f, l = factorize(base), []
    for factor in f:
        ans, n = 0, number
        while n >= factor:
            ans += n // factor
            n = n // factor
        ans = ans // f[factor]
        l.append(ans)
    return min(l)

def zeroes (b, n):
  d1={} #for decomposition of base into power of primefactors
  i=2
  while b>1:
    while b%i==0:
      try:
        d1[i]+=1
      except KeyError:
        d1[i]=1
      b//=i
    i+=1
  d2={} #for total powers of the primefactors in the number
  for i in d1:
    s=0
    r=i
    while r<=n:
      s+=n//r
      r*=i
    d2[i]=s
  return min(list(d2[i]//d1[i] for i in d1))


def zeroes (base, number):
    fc = get_factor(base)
    return min([find_power(number, i) // fc.count(i) for i in set(fc)])

def get_factor(n):
    li, j = [], 2
    while j * j <= n:
        if n % j : j += 1;continue
        li.append(j)
        n //= j
    if n > 0 : li.append(n)
    return li
    
def find_power(k, b):
    n, c = b, 0
    while k // n:
        c += k // n
        n *= b
    return c

import re

# fixme
def zeroes (base, number):
    i = 2
    factors = []
    while i * i <= base:
        if base % i:
            i += 1
        else:
            base //= i
            factors.append(i)
    if base > 1:
        factors.append(base)
        
    count=99999999999999999999
    for i in set(factors):
        sum=number//i
        temp=sum
        while temp>=i:
            temp//=i
            sum+=temp
        sum//=factors.count(i) 
        if sum < count:
            count=sum
      
    return count