Chains of 0's

The function

f ( x , y , z ) = x x y + x y z \displaystyle f(x, y, z) = x^{x^y} + x^{y^z}

for all positive integers. What is the length of the longest chain of consecutive 0's in the simplified form of

f ( 4 , 5 , 6 ) f(4, 5, 6)


The answer is 3.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

6 solutions

Thaddeus Abiy
Aug 2, 2014

Python Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
def f(x,y,z):
    return x**(x**y) + x**(y**z)

N = str(f(4,5,6))
Size = len(N)

Longest = 0
i = 0

while i < Size:
    Count = 0
    j = i
    while j < Size:
        Char = N[j]
        if Char == "0":
            j += 1
            Count += 1
        else:
            break
    i = j
    Longest = max( Longest , Count )

print Longest

The program first converts (f(4,5,6)) into a string. It then goes through each digit one at a time until it finds a zero. If the zero is the first of a continuous sub sequence of zeros,the program activates another loop and counts the size of the sub-sequence and checks if it is the longest sub-sequence found so far.

How many hours were used for computation?

Kenny Lau - 6 years, 8 months ago
Hunter Killer
Jan 6, 2015

Mathematica Code

1
2
3
4
5
6
f[x_, y_, z_] := x^x^y + x^y^z;
a = f[4, 5, 6];
b = IntegerDigits[a];
c = Split[b];
d = Cases[c, {0 ..}];
Max[Length /@ d]

It takes 0.02 sec

Tarun Singh
Feb 2, 2015

how i solved it,

1
2
3
4
5
6
7
8
a=str( 4**(4**5)+4**(5**6))
if True:
    x='' 
    for i in range(20):   #assuming max consecutive zeros to be 20
        x+='0'           #x will increment to number of zeroes
        if x in a:         #check if this much consecutive zeroes exist in a
            print x
#0.07200407981872559 seconds

Ruby Code:

def f(x,y,z)
  return x**(x**y) + x**(y**z)
end

a = f(4,5,6).to_s.split(/[^0]/) - [""] #return array containing only strings of 0s.
z = 0
a.each { |zeros| z = zeros.size if zeros.size > z}

z = 3

Mharfe Micaroz
Oct 30, 2014

Additional problem: What digit therefore has the longest chain?

Answer: Digit 1 (length of longest chain is 4)

Mathematica Code

1
2
3
4
5
f[x_, y_, z_] := x^x^y + x^y^z
a = f[4, 5, 6];
b = IntegerDigits[a];
c = Split[b];
d = Table[Max[Length /@ Cases[c, {i ..}]], {i, 0, 9}]

Hunter Killer - 6 years, 5 months ago

Using Python code as follows:

 f = x**(x**y)+x**(y**z)
 s = str(f)
 n = 0
 m = 0
 z = 'N'
 for i in range(len(s)):
      if int(s[i])==0:
            m+= 1
    z = 'Y'
elif int(s[i]) > 0 and z == 'Y':
    if m > n:
        n = m
    print m, n
    m = 0
    z = 'N'

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...