Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6379 |

@blackshadows | 6329 |

@mb1973 | 5358 |

@Quandray | 5231 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4510 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3357 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@ritiksethi21 | 1050 |

@aroranayan999 | 807 |

@RizulBansal | 685 |

@ashishtrehan002 | 538 |

@hemantgarg923 | 528 |

@simrangoyal | 526 |

@ronaldo77 | 520 |

@thanosagain | 505 |

@anishrajan | 505 |

@ssparteek470 | 495 |

@rahul2312 | 491 |

Complete Leaderboard |

Juggler Sequence is a series of integers in which the first term starts with a positive integer number *a* and the remaining terms are generated from the immediate previous term using the below recurrence relation:

Given a number N, find the Juggler Sequence for this number as the first term of the sequence.

**Example 1:**

**Input:** N = 9
**Output:** 9 27 140 11 36 6 2 1
**Explaination:** We start with 9 and use
above formula to get next terms.

**Example 2:**

**Input:** N = 6
**Output:** 6 2 1
**Explaination:**
6^{1/2} = 2.
2^{1/2} = 1.

**Your Task:**

You do not need to read input or print anything. Your Task is to complete the function** jugglerSequence()** which takes N as input parameter and returns a list of integers denoting the generated sequence.

**Expected Time Complexity:** O(N)

**Expected Auxiliary Space:** O(N)

**Constraints:**

1 ≤ N ≤ 100

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Juggler Sequence

...