Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • DSA
  • Practice Pattern Searching
  • Tutorial on Pattern Searching
  • Naive Pattern Searching
  • Rabin Karp
  • KMP Algorithm
  • Z Algorithm
  • Trie for Pattern Seaching
  • Manacher Algorithm
  • Suffix Tree
  • Ukkonen's Suffix Tree Construction
  • Boyer Moore
  • Aho-Corasick Algorithm
  • Wildcard Pattern Matching
Open In App
Next Article:
Sum of area of alternative concentric circle with radius 1,2,3,4..........N
Next article icon

Sum of area of alternative concentric circle with radius 1,2,3,4..........N

Last Updated : 20 Jan, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

Given that Concentric circle of radii 1,2,3,4..........N cm are drawn. The interior of the smallest circle is colored white and angular regions are colored alternately green and white so that no two adjacent regions are of the same color. The task is to find the total area of the green region in sq cm.

Examples:

Input: N=100
Output: 15865.042900628456

Input: N=10
Output: 172.78759594743863

Approach: Area of the first green region would be-

[?(R2²- R1²)]

Similarly, the area of all alternative green circles would be-

[?(R4²- R3²)], [?(R6²- R5²)].....

The total area of the green region is the sum of the area of the green region is-

A  =  [ ? { (R2² - R1²) + (R4² - R3²) + (R6² - R5²) ............. (R(N)² -  R(N-1)²}]

A =   [ ? { ((R2 - R1)(R2 + R1)) + ((R4 - R3)(R4 + R3)) + ((R6 - R5)(R6 + R5)) ............. ((RN -  R(N - 1)(RN + R(N - 1)) } ]

Since the difference between the radius of 2 concentric circles is only 1 cm so R(N) - R(N - 1) = 1. Hence,

A  =   [ ? {R1 + R2 + R3 + R4 + R5 + R6 .............R(N-1) + R(N) } ]

(R1 + R2 + R3 + R4 + R5 + R6 .............R(N-1) + R(N) forms an arithmetic progression so we have to find the sum of arithmetic progression with starting radius as 1 and last radius as N with a common difference of 1.

Sum of A.P. is-

SN = N * (2 * a +(N - 1) * d) / 2  

or 

SN = N * (a + l) / 2

Thus, the area of the green region is-

A = Sn * ? 

Below is the implementation of the above approach:

C++
// C++ code for the above approach #include <bits/stdc++.h> using namespace std;  // Function to calculate area // of concentric circles double area(int N, int a, int l) {      // Formula to find sum of     // Arithmetic Progression     double S = N * (a + l) / 2;      // return area     return S * M_PI; }  // Driver code int main() {        // N is number of concentric circles     int N = 100;      // Radius of interior circle     int a = 1;      // l radius of exterior circle     int l = N;      // r is result     double r = area(N, a, l);      // Print result     cout << fixed << setprecision(12) << r; }  // This code is contributed by Samim Hossain Mondal. 
Java
// Java code for the above approach class GFG {    // Function to calculate area // of concentric circles static double area(int N, int a, int l) {      // Formula to find sum of     // Arithmetic Progression     double S = N * (a + l) / 2;      // return area     return S * Math.PI; }  // Driver code public static void main(String args[]) {        // N is number of concentric circles     int N = 100;      // Radius of interior circle     int a = 1;      // l radius of exterior circle     int l = N;      // r is result     double r = area(N, a, l);      // Print result     System.out.println(r); } }  // This code is contributed by gfgking 
Python3
# import pi from math module from math import pi  # Function to calculate area  # of concentric circles def area(N,a):            # Formula to find sum of      # Arithmetic Progression     S = N * (a + l) / 2          # return area     return S * pi  # N is number of concentric circles N = 100  # Radius of interior circle a = 1  # l radius of exterior circle l = N  # r is result  r = area(N, a)  # Print result print(r) 
C#
// C# program for the above approach using System; class GFG {    // Function to calculate area   // of concentric circles   static double area(int N, int a, int l)   {      // Formula to find sum of     // Arithmetic Progression     double S = N * (a + l) / 2;      // return area     return S * Math.PI;   }    // Driver Code:   public static void Main()   {     // N is number of concentric circles     int N = 100;      // Radius of interior circle     int a = 1;      // l radius of exterior circle     int l = N;      // r is result     double r = area(N, a, l);      // Print result     Console.WriteLine(r);   } }  // This code is contributed by Samim Hossain Mondal. 
JavaScript
 <script>         // JavaScript code for the above approach           // Function to calculate area          // of concentric circles         function area(N, a) {              // Formula to find sum of              // Arithmetic Progression             S = N * (a + l) / 2              // return area             return S * Math.PI         }                  // N is number of concentric circles         N = 100          // Radius of interior circle         a = 1          // l radius of exterior circle         l = N          // r is result          r = area(N, a)          // Print result         document.write(r)            // This code is contributed by Potta Lokesh     </script> 

 
 


Output
15865.042900628456


 

Time Complexity: O(1) 
Auxiliary Space: O(1)


 


Next Article
Sum of area of alternative concentric circle with radius 1,2,3,4..........N

H

harshdeepmahajan88
Improve
Article Tags :
  • Pattern Searching
  • Mathematical
  • Geometric
  • DSA
  • area-volume-programs
  • Circles
Practice Tags :
  • Geometric
  • Mathematical
  • Pattern Searching

Similar Reads

    Radius of a circle having area equal to the sum of area of the circles having given radii
    Given two integers r1 and r2, representing the radius of two circles, the task is to find the radius of the circle having area equal to the sum of the area of the two circles having given radii. Examples: Input:r1 = 8r2 = 6Output:10Explanation:Area of circle with radius 8 = 201.061929 Area of a circ
    4 min read
    Area of Equilateral triangle inscribed in a Circle of radius R
    Given an integer R which denotes the radius of a circle, the task is to find the area of an equilateral triangle inscribed in this circle. Examples: Input: R = 4 Output: 20.784 Explanation: Area of equilateral triangle inscribed in a circle of radius R will be 20.784, whereas side of the triangle wi
    4 min read
    Program to calculate the area between two Concentric Circles
    Given two concentric circles with radius X and Y where (X > Y). Find the area between them. You are required to find the area of the green region as shown in the following image: Examples: Input : X = 2, Y = 1 Output : 9.42478 Input : X = 4, Y = 2 Output : 37.6991 Approach:The area between the tw
    4 min read
    Count points from an array that lies inside a semi-circle
    Given two pairs (X, Y), (P, Q) and R the coordinate of the center of semi-circle, coordinate of the intersection of semicircle and diameter of the semicircle and, the radius of the semicircle, and an array arr[] of dimension N*2 consisting of the coordinates of few points, the task is to find the nu
    7 min read
    Sum of first n terms of a given series 3, 6, 11, .....
    Given a series and a number n, the task is to find the sum of its first n terms. Below is the series: 3, 6, 11, 20, .... Examples: Input: N = 2 Output: 9 The sum of first 2 terms of Series is 3 + 6 = 9 Input: N = 3 Output: 20 The sum of first 3 terms of Series is 3 + 6 + 11 = 20 Approach: This probl
    5 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences