Skip to content
This repository has been archived by the owner on Oct 14, 2021. It is now read-only.

Leibniz's formula for calculating pi #278

Closed
Archie4575 opened this issue Oct 25, 2020 · 10 comments
Closed

Leibniz's formula for calculating pi #278

Archie4575 opened this issue Oct 25, 2020 · 10 comments

Comments

@Archie4575
Copy link
Contributor

Archie4575 commented Oct 25, 2020

The following formula is named after Gottfried Wilhelm von Leibniz, a prominent German polymath who lived from 1646-1716.

Leibniz pattern

or

Leibniz sigma

This program will iterate over this pattern 'k' times, with 'k' being defined by the user. The larger the value of 'k',
the closer the approximation of pi.

I already have already made a stand-alone C++ program! here, which I will convert to a function and add to this project. This function prototype will be as follows:

long double leibniz(int k);

If someone wants to do the same with another language, feel free.

@aditya109
Copy link
Owner

Hi @Archie4575 ! Please go on ahead and raise a PR for the same, linking this issue. I am assigning this issue to you. Please consider starring the repo, if you have not already to encourage further contributions.

@Archie4575
Copy link
Contributor Author

Yeah, sweet. Should I leave the thread open for those who might want to write it in another language? @aditya109

@gustavoplenamente
Copy link
Contributor

gustavoplenamente commented Oct 25, 2020

I would like to add content to this issue in C, Java, Python and Javascript.
Is there a version standard to be followed?

@hryxna
Copy link
Collaborator

hryxna commented Oct 25, 2020

@aditya109 I would like to give it a try as well 😄.
@Archie4575 I have a doubt regarding the formula, So basically we have to implement the formula in a loop running "K" times, and then we have to check our ans for the approximation correct? 😅.
Correct me if I'm getting the wrong idea

@hryxna
Copy link
Collaborator

hryxna commented Oct 25, 2020

we can also use recursion if I'm not wrong 🤔

@Archie4575
Copy link
Contributor Author

@hryxna yeah just loop it. You can divide your answer by the actual Pi to get a percentage accuracy if you want. Also I’m not sure if using recursion would be advantageous and it also might run into a maximum recursion depth.

@Archie4575
Copy link
Contributor Author

@gustavoplenamente yeah go ahead. Don’t worry about a version standard.

@gustavoplenamente
Copy link
Contributor

Yeah, recursion would add space complexity to the solution.

@hryxna
Copy link
Collaborator

hryxna commented Oct 25, 2020

Don't worry @Archie4575 & @gustavoplenamente I won't just directly go for recursion though 😬.
Because even I know it may cause an error for higher inputs so Best Case Scenario is a loop and run-time complexity would be O(n) in that case 😁

@purva-saxena
Copy link

can you please assign this task to me??

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants