Aspire's Library

A Place for Latest Exam wise Questions, Videos, Previous Year Papers,
Study Stuff for MCA Examinations - NIMCET

Previous Year Question (PYQs)



A hand-held gaming device takes $X$ and $Y$ as two input values. These values get updated as $X=XY/2$ and $Y=Y+1$ at each iteration and the game stops when $X$ is greater than or equal to $N$. For $X=2$, $Y=4$ and $N=3000$, what would be the final value of $X$ when the game stops?





Solution

Given initial values:

$X=2,\quad Y=4$

Rule:

$X=\frac{XY}{2}$ and $Y=Y+1$

Now update step by step:

First iteration:

$X=\frac{2\times 4}{2}=4,\quad Y=5$

Second iteration:

$X=\frac{4\times 5}{2}=10,\quad Y=6$

Third iteration:

$X=\frac{10\times 6}{2}=30,\quad Y=7$

Fourth iteration:

$X=\frac{30\times 7}{2}=105,\quad Y=8$

Fifth iteration:

$X=\frac{105\times 8}{2}=420,\quad Y=9$

Sixth iteration:

$X=\frac{420\times 9}{2}=1890,\quad Y=10$

Seventh iteration:

$X=\frac{1890\times 10}{2}=9450$

Now $X=9450$, which is greater than $3000$.

So, the game stops.

Therefore, the final value of $X$ is $9450$.



Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More

Ask Your Question or Put Your Review.

loading...