generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Why doesn't this work?

Previous Thread :: Next Thread 
Gladii is not online. 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 is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
21 Jan 2015 02:25 PM
Help?
Report Abuse
crossbar is not online. 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 is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
21 Jan 2015 02:32 PM
What do you mean?
Report Abuse
Gladii is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
21 Jan 2015 02:45 PM
No more help?
Report Abuse
crossbar is not online. 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 is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
21 Jan 2015 02:48 PM
Just for fun,
Report Abuse
crossbar is not online. 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 is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
21 Jan 2015 02:57 PM
I've memorized about 10 digits tho...
Report Abuse
soEPIC123TNT is not online. soEPIC123TNT
Joined: 16 Jun 2013
Total Posts: 46
21 Jan 2015 03:14 PM
you missed out a few locals
Report Abuse
Gladii is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
21 Jan 2015 05:21 PM
can you tell me what "local"?
Report Abuse
Gladii is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
21 Jan 2015 05:47 PM
bump
Report Abuse
DoAndDoOver is not online. DoAndDoOver
Joined: 06 Sep 2014
Total Posts: 628
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 is not online. 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 is not online. Sercity
Joined: 07 Jul 2014
Total Posts: 156
21 Jan 2015 06:05 PM
math.pi

idk
Report Abuse
powertool is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. Gladii
Joined: 10 Mar 2012
Total Posts: 1713
21 Jan 2015 06:10 PM
Thanks powertool!
Report Abuse
powertool is not online. 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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image