Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
|
| 21 Jan 2015 02:09 PM |
I'm trying the Nilakantha series to calculate pi. It ends up as 3.16(6 repeating)
pi = 3 count = 2 while true do pi = pi + (4/(count*((count+1)*(count+2)))) count = count + 2 pi = pi - (4/(count*((count+1)*(count+2)))) wait() print(pi) end |
|
|
| Report Abuse |
|
|
Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
| |
|
crossbar
|
  |
| Joined: 08 Dec 2009 |
| Total Posts: 2817 |
|
|
| 21 Jan 2015 02:31 PM |
| use the regular pi number the computer would have a hard time keeping up also |
|
|
| Report Abuse |
|
|
Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
| |
|
Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
| |
|
crossbar
|
  |
| Joined: 08 Dec 2009 |
| Total Posts: 2817 |
|
|
| 21 Jan 2015 02:47 PM |
whats wrong with using 3 point 1415 etc. ?
Why do you need such exact numbers for pi? |
|
|
| Report Abuse |
|
|
Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
| |
|
crossbar
|
  |
| Joined: 08 Dec 2009 |
| Total Posts: 2817 |
|
|
| 21 Jan 2015 02:53 PM |
Oh, that is really hard then.
There are programs on the internet dedicated to doing that you can download. By using atan and with quite a few blocks of code you would only get pi up to 14 digits xP |
|
|
| Report Abuse |
|
|
Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
|
| 21 Jan 2015 02:57 PM |
| I've memorized about 10 digits tho... |
|
|
| Report Abuse |
|
|
|
| 21 Jan 2015 03:14 PM |
| you missed out a few locals |
|
|
| Report Abuse |
|
|
Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
|
| 21 Jan 2015 05:21 PM |
| can you tell me what "local"? |
|
|
| Report Abuse |
|
|
Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
| |
|
|
| 21 Jan 2015 05:56 PM |
local pi = 3 local count = 2 while true do pi = pi + (4/(count*((count+1)*(count+2)))) count = count + 2 pi = pi - (4/(count*((count+1)*(count+2)))) wait() print(pi) end
the word local makes it so that the variables only work locally, as in in that script, if you put it in a function or a do block or something, it would only work in that function
which is useful
ex.
do local pi = 3 local count = 2 while true do pi = pi + (4/(count*((count+1)*(count+2)))) count = count + 2 pi = pi - (4/(count*((count+1)*(count+2)))) wait() print(pi) end end |
|
|
| Report Abuse |
|
|
powertool
|
  |
| Joined: 01 Feb 2008 |
| Total Posts: 3771 |
|
|
| 21 Jan 2015 06:04 PM |
function nikal(init, count, num, rep) fin = init for i = 1, rep do
fin = (fin+(num/((count)*(count+1)*(count+2)))) count = count+2
fin = (fin-(num/((count)*(count+1)*(count+2)))) count = count+2 --THIS IS WAHT YOU"RE FORGETTING end return fin end
You need to run it a lolhueg number of times. |
|
|
| Report Abuse |
|
|
Sercity
|
  |
| Joined: 07 Jul 2014 |
| Total Posts: 156 |
|
| |
|
powertool
|
  |
| Joined: 01 Feb 2008 |
| Total Posts: 3771 |
|
|
| 21 Jan 2015 06:06 PM |
| Sercity the idea is to use a function (specifically the nikalantha series) to calculate pi, for fun. |
|
|
| Report Abuse |
|
|
Sercity
|
  |
| Joined: 07 Jul 2014 |
| Total Posts: 156 |
|
|
| 21 Jan 2015 06:06 PM |
| if your goal is to print pi why wouldn't you just use "print(math.pi)" |
|
|
| Report Abuse |
|
|
powertool
|
  |
| Joined: 01 Feb 2008 |
| Total Posts: 3771 |
|
|
| 21 Jan 2015 06:07 PM |
The goal is to return pi BY USING THE NIKALANTHA SERIES.
Idiot. |
|
|
| Report Abuse |
|
|
Sercity
|
  |
| Joined: 07 Jul 2014 |
| Total Posts: 156 |
|
|
| 21 Jan 2015 06:07 PM |
@powertool oh well here's your function then!!!
function pi() print(math.pi) end pi() |
|
|
| Report Abuse |
|
|
Sercity
|
  |
| Joined: 07 Jul 2014 |
| Total Posts: 156 |
|
|
| 21 Jan 2015 06:08 PM |
oh. well i guess i posted that too soon |
|
|
| Report Abuse |
|
|
powertool
|
  |
| Joined: 01 Feb 2008 |
| Total Posts: 3771 |
|
|
| 21 Jan 2015 06:09 PM |
function nikal(init, count, num, rep) fin = init for i = 1, rep do
fin = (fin+(num/((count)*(count+1)*(count+2)))) count = count+2
fin = (fin-(num/((count)*(count+1)*(count+2)))) count = count+2 --THIS IS WAHT YOU"RE FORGETTING end return fin end
io.write("Initial value?") one = io.read()
io.write("Counter initial?") two = io.read()
io.write("Numerator?") three = io.read()
io.write("Repetitions?") four = io.read()
nikal(one,two,three,four)
Far better function for calculating pi. If you're trying to use a nikalantha series to calculate pi. Math.pi is boring af. |
|
|
| Report Abuse |
|
|
Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
| |
|
powertool
|
  |
| Joined: 01 Feb 2008 |
| Total Posts: 3771 |
|
|
| 21 Jan 2015 06:10 PM |
| Took me five mins to into the math, and a minute to write it on my phone. |
|
|
| Report Abuse |
|
|
Gladii
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 1713 |
|
|
| 21 Jan 2015 06:14 PM |
Is there a way to stop roblox to stop limiting the ammount of non-Whole numbers? It only goes to 3.1415926535897 (which is accurate)
|
|
|
| Report Abuse |
|
|
Sercity
|
  |
| Joined: 07 Jul 2014 |
| Total Posts: 156 |
|
|
| 21 Jan 2015 06:19 PM |
@gladii well it would probably crash your computer with thousands of decimal places unless you specifically scripted a limit of numbers (which could be difficult)
i think 3.1415926535897 is as accurate as you're going to get |
|
|
| Report Abuse |
|
|