Given a positive integer n, find the number of distinct routes a spaceship can take to travel to a planet that is n wormholes away from Earth, where the spaceship can travel either by taking a single wormhole or a pair of wormholes at a time. The number of distinct routes is given by the formula: n + n*(n-1)/2.
Explanation: Step-by-step: with input n = 5, we calculate the number of distinct routes as follows: - Single wormhole routes: 5 - Pair of wormhole routes: 5*(5-1)/2 = 10 - Total distinct routes: 5 + 10 = 15
Explanation: Step-by-step: with input n = 10, we calculate the number of distinct routes as follows: - Single wormhole routes: 10 - Pair of wormhole routes: 10*(10-1)/2 = 45 - Total distinct routes: 10 + 45 = 55
Master coding challenges related to Recursion and solve the [Backup] Intergalactic Travel Planner problem optimally.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak