

A080342


Number of weighings required to identify a single bad coin out of n coins, using a twopan balance.


4



0, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

1,4


COMMENTS

It is known that there is exactly one bad coin, which is heavier than the others. No weights are used in the weighings.
0 appears once, 1 twice, 2 6 times, 3 18 times, 4 54 times, ... which is the same as the number of base3 numbers of length n; see A007089.  Jonathan Vos Post, Apr 20 2011
Records appear at positions 3^n+1 (=A034472(n)).  Robert G. Wilson v, Aug 06 2012
The "Heavy Marble" section of "Brainteaser Problems" in the Mongan et al. reference describes the n = 8 case in detail and then derives the general formula given below. Of course this sequence applies also when the single, unlike object is lighter than all the others. If the unlike object is only known to have a different weight (that is, to be lighter than all the others or heavier than all the others), use A064099.  Rick L. Shepherd, Sep 05 2013
If it is unknown whether the bad coin is heavier or lighter, then the minimum number of weighings is A029837(n) and the number of coins that must be used in the first weighing is A004526(n), for n > 2.  Ivan N. Ianakiev, Apr 13 2017


REFERENCES

J. Mongan, N. Suojanen, and E. GiguĂ¨re, Programming Interviews Exposed: Secrets to Landing Your Next Job, 2nd Edition, Wiley Publishing, Inc., 2007, pp. 169172.


LINKS

Rick L. Shepherd, Table of n, a(n) for n = 1..10000
R. K. Guy, R. J. Nowakowski, Coinweighing problems, Am. Math. Monthly 102 (2) (1995) 164167.
B. Manvel, Counterfeit coin problems, Math. Mag. 50 (2) (1977) 9092, theorem 1.


FORMULA

a(n) = floor(L)  floor(2^(f(L))) + 1, where L = log_3(n) and f() = fractional part.
a(n) = ceiling(log_3(n)).  Rick L. Shepherd, Sep 05 2013
A064235(n) = 3 ^ a(n).  Reinhard Zumkeller, Sep 02 2015


EXAMPLE

a(1) = 0 since no weighings are needed  the coin is bad. a(2) = 1 since one weighing is needed.


MATHEMATICA

f[n_] := Floor[ Log[3, n]]  Floor[2^FractionalPart[ Log[3, n]]] + 1; Array[f, 105] (* Robert G. Wilson v, Aug 05 2012 *)


PROG

(PARI) a(n) = ceil(log(n)/log(3)) \\ Rick L. Shepherd, Sep 05 2013
(Haskell)
import Data.List (transpose)
a080342 n = genericIndex a080342_list (n  1)
a080342_list = 0 : zs where
zs = 1 : 1 : (map (+ 1) $ concat $ transpose [zs, zs, zs])
 Reinhard Zumkeller, Sep 02 2015


CROSSREFS

Cf. A000244, A007089, A025192, A064235.
Cf. also A004526, A029837, A064099.
Sequence in context: A211664 A182434 A185679 * A081604 A123119 A099396
Adjacent sequences: A080339 A080340 A080341 * A080343 A080344 A080345


KEYWORD

nonn,easy


AUTHOR

Artemario Tadeu Medeiros da Silva (artemario(AT)uol.com.br), Mar 19 2003


STATUS

approved



