Given **r** is the radius of three equal circles touching each other. The task is to find the length of the rope tied around the circles as shown below:

**Examples:**

Input:r = 7

Output:86

Input:r = 14

Output:172

**Approach:** As it can be clearly seen from above image, the part of the length of rope which is not touching the circle is **2r + 2r + 2r = 6r**.

The part of the rope which is touching the circles make a sector of 120 degrees on each circle. Thus, three sectors of 120 degrees each can be considered as a complete one circle of 360 degrees.

Therefore, Length of rope touching the circle is **2 * PI * r** where **PI = 22 / 7** and **r** is the radius of the circle.

Hence, the total length of the rope will be **( 2 * PI * r ) + 6r**.

Below is the implementation of the above approach:

## CPP

`// C++ program to find the length ` `// of rope ` `#include<bits/stdc++.h> ` `using` `namespace` `std; ` `#define PI 3.14159265 ` ` ` `// Function to find the length ` `// of rope ` `float` `length_rope( ` `float` `r ) ` `{ ` ` ` `return` `( ( 2 * PI * r ) + 6 * r ); ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `float` `r = 7; ` ` ` `cout<<` `ceil` `(length_rope( r ))<<endl; ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## C

`// C program to find the length ` `// of rope ` `#include <stdio.h> ` `#define PI 3.14159265 ` ` ` `// Function to find the length ` `// of rope ` `float` `length_rope( ` `float` `r ) ` `{ ` ` ` `return` `( ( 2 * PI * r ) + 6 * r ); ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `float` `r = 7; ` ` ` `printf` `(` `"%f"` `, ` ` ` `length_rope( r )); ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java code to find the length ` `// of rope ` `import` `java.lang.*; ` ` ` `class` `GFG { ` ` ` ` ` `static` `double` `PI = ` `3.14159265` `; ` ` ` ` ` `// Function to find the length ` ` ` `// of rope ` ` ` `public` `static` `double` `length_rope(` `double` `r) ` ` ` `{ ` ` ` `return` `((` `2` `* PI * r) + ` `6` `* r); ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `main(String[] args) ` ` ` `{ ` ` ` `double` `r = ` `7` `; ` ` ` `System.out.println(length_rope(r)); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 code to find the length ` `# of rope ` `PI ` `=` `3.14159265` ` ` `# Function to find the length ` `# of rope ` `def` `length_rope( r ): ` ` ` `return` `( ( ` `2` `*` `PI ` `*` `r ) ` `+` `6` `*` `r ) ` ` ` `# Driver code ` `r ` `=` `7` `print` `( length_rope( r )) ` |

*chevron_right*

*filter_none*

## C#

`// C# code to find the length ` `// of rope ` `using` `System; ` ` ` `class` `GFG { ` ` ` `static` `double` `PI = 3.14159265; ` ` ` ` ` `// Function to find the length ` ` ` `// of rope ` ` ` `public` `static` `double` `length_rope(` `double` `r) ` ` ` `{ ` ` ` `return` `((2 * PI * r) + 6 * r); ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `Main() ` ` ` `{ ` ` ` `double` `r = 7.0; ` ` ` `Console.Write(length_rope(r)); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP program to find the ` `// length of rope ` `$PI` `= 3.14159265; ` ` ` `// Function to find the length ` `// of rope ` `function` `length_rope( ` `$r` `) ` `{ ` ` ` `global` `$PI` `; ` ` ` `return` `( ( 2 * ` `$PI` `* ` `$r` `) + 6 * ` `$r` `); ` `} ` ` ` `// Driver code ` `$r` `=7; ` `echo` `(length_rope( ` `$r` `)); ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

86

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Length of the direct common tangent between two externally touching circles
- Probability of cutting a rope into three pieces such that the sides form a triangle
- Calculate Stirling numbers which represents the number of ways to arrange r objects around n different circles
- Ratio of the distance between the centers of the circles and the point of intersection of two direct common tangents to the circles
- Ratio of the distance between the centers of the circles and the point of intersection of two transverse common tangents to the circles
- Check if two given circles touch or intersect each other
- Radii of the three tangent circles of equal radius which are inscribed within a circle of given radius
- Radius of the inscribed circle within three tangent circles
- Check whether given circle resides in boundary maintained by two other circles
- Puzzle | Connect 9 circles each arranged at center of a Matrix using 3 straight lines
- Length of the transverse common tangent between the two non intersecting circles
- Length of direct common tangent between the two non-intersecting Circles
- Length of direct common tangent between two intersecting Circles
- Distance between centers of two intersecting circles if the radii and common chord length is given
- Length of the perpendicular bisector of the line joining the centers of two circles
- Number of quadruples where the first three terms are in AP and last three terms are in GP
- Length of a Diagonal of a Parallelogram using the length of Sides and the other Diagonal
- Permutations to arrange N persons around a circular table
- Seating arrangement of n boys and girls alternatively around a round table
- Seating arrangement of N boys sitting around a round table such that two particular boys sit together

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.