Answer
$34.31$ years.
Work Step by Step
Use the given formula $A=P(1-r)^n$
where $P$ is the principal, the amount now, $r$ is the annual inflation rate, $n$ is the number of years, $A$ is the amount $P$ will be worth back after $n$ years
Here
$P=2A$ (because the purchasing power is cut in half)
$r=0.02$
Hence $A=2A(1-0.02)^n\\\frac{1}{2}=0.98^n\\0.5=0.98^n\\\log_{0.98}{0.5}=\log_{0.98}{0.98^n}\\\log_{0.98}{0.5}=n.$
Therefore by using a calculator $n=\log_{0.98}{0.5}=34.31$ years.