In this post, we will solve **Jumping Bunnies HackerRank Solution**. This problem **(Jumping Bunnies)** is a part of **HackerRank Functional Programming** series.

**Task**

Bunnies are very cute animals who likes to jump a lot. Every bunny has his own range of jump. Lets say there are * N* bunnies and

*i*^{th}**(**bunny jumps

*i*∈ [1,*N*])*units. Consider a 1-D plane, where initially bunnies are at*

**j**_{i}**0**. All of them starts jumping in forward direction.

For example, consider the case of ** k^{th}** bunny. Initially he is at

**0**. After first jump, he will be at point

**. After second, he will be at**

*j*_{k}**2 x**and so on. After

*j*_{k}*jump, he will be at point*

**m**^{th}**.**

*m*x*j*_{k}Two bunnies can only meet each other when they are on the ground. When on the ground, a bunny can wait any amount of time. Being a social animal, all of them decide to meet at the next point where *all* of them will be on the ground. You have to find the nearest point where all the bunnies can meet.

For example, if there are ** N = 3** bunnies where

**,**

*j*_{1}= 2**,**

*j*_{2}= 3**. Nearest point where all bunnies can meet again is at**

*j*_{3}= 4**12**. First bunny has to jump six times, for second it is

**4**times and for third it is

**3**times.

Help bunnies to find the nearest point where they can meet again.

**Input Format**

First line will contain an integer, * N*, representing the number of bunnies. Second line will contain

*space separated integer,*

**N****,**

*j*_{1}*,*

**j**_{2}**representing the jumping distance of them.**

*. . . j*_{N},**Output Format**

Print the nearest location where all bunnies can meet again.

**Constraints**

**2 <=***N*<= 10**1 <=***j*<= 10_{i}^{6}- For each test case it is guaranteed that solution will not exceed
**2 x 10**.^{18}

**Sample Input #00**

```
3
2 3 4
```

**Sample Output #00**

`12`

**Sample Input #01**

```
2
1 3
```

**Sample Output #01**

`3`

**Explanation**

*Sample Case #00:* This is the same example mentioned in the statement above.*Sample Case #01:* First bunny has to jump **3** times to point **3**, whereas second bunny has to jump only one time to go at point . Point **3** will serve as their meeting point.

**Solution – Jumping Bunnies – HackerRank Solution**

**Scala**

import java.util.Scanner object Solution { @scala.annotation.tailrec def gcd(a: Long, b: Long): Long = if (b == 0) a else gcd(b, a % b) def lcm(a: Long, b: Long): Long = a / gcd(a, b) * b def main(args: Array[String]): Unit = { val sc = new Scanner(System.in) val t = sc.nextInt println((0 until t).map(_ => sc.nextLong).reduce(lcm)) } }

**Note: **This problem **(Jumping Bunnies)** is generated by **HackerRank **but the solution is provided by **CodingBroz**. This tutorial is only for **Educational** and **Learning** purpose.