English
Tamil Nadu Board of Secondary EducationHSC Science Class 11

King Vikramaditya has two magic swords. With one, he can cut off 19 heads of a dragon, but after that, the dragon grows 13 heads. With the other sword, he can cut off 7 heads, but 22 new heads grow. - Computer Science

Advertisements
Advertisements

Question

King Vikramaditya has two magic swords. With one, he can cut off 19 heads of a dragon, but after that, the dragon grows 13 heads. With the other sword, he can cut off 7 heads, but 22 new heads grow. If all heads are cut off, the dragon dies. If the dragon has originally 1000 heads, can it ever die?

Sum

Solution

No. of heads of dragon = 1000
sword 1: cuts 19 heads but 13 heads grow back.
sword 2: cuts 7 heads but 22 heads grow back.
Let n be the number of heads of the dragon at the initial state.

Case 1: King uses Sword 1
Sword 1 cuts off 19 heads but 13 heads grow back.
n : = n – 19 + 13 = n – 6 No. of heads are reduced by 6.

Case 2: King uses Sword 2
Sword 2 cuts 7 heads but 22 heads grow back.
n : = n – 7 + 22 = n + 15
No. of heads are increased by 15.

shaalaa.com
Invariants
  Is there an error in this question or solution?
Chapter 8: Iteration and recursion - Evaluation - Section - C [Page 114]

APPEARS IN

Samacheer Kalvi Computer Science [English] Class 11 TN Board
Chapter 8 Iteration and recursion
Evaluation - Section - C | Q 3. | Page 114
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×