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: scripting challenge

Previous Thread :: Next Thread 
lostend is not online. lostend
Joined: 21 Aug 2011
Total Posts: 8265
27 Sep 2015 09:35 PM
find the square root of a number without using math.sqrt or decimal exponents (e.g. x^.5)
Report Abuse
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
27 Sep 2015 09:43 PM
function squirt(x)
local try = 0
repeat
try = try+1e-010
until (try^2)-.0001<=x<=(try^2)+.0001 or x/2<=try
return x/2<=try and "No Root Found" or try
end

Perhaps?
Report Abuse
morashsPeasant is not online. morashsPeasant
Joined: 06 Jan 2011
Total Posts: 4944
27 Sep 2015 09:43 PM
lol you silly's square root is essentially the something to the power of a half!!

function sqart(num)
return num^(1/2)
end

print(sqart(22))

morashsPeasant is worshipping Dermon
Report Abuse
morashsPeasant is not online. morashsPeasant
Joined: 06 Jan 2011
Total Posts: 4944
27 Sep 2015 09:44 PM
something to the power of a half**

morashsPeasant is eating
Report Abuse
TickerOfTime is not online. TickerOfTime
Joined: 02 Sep 2012
Total Posts: 2030
27 Sep 2015 09:44 PM
He said no decimal exponents..
Report Abuse
morashsPeasant is not online. morashsPeasant
Joined: 06 Jan 2011
Total Posts: 4944
27 Sep 2015 09:45 PM
lol i cri evertim

morashsPeasant is Dermon
Report Abuse
morashsPeasant is not online. morashsPeasant
Joined: 06 Jan 2011
Total Posts: 4944
27 Sep 2015 09:47 PM
Ok, I still win

function sqart(num)
return math.log(num)/math.log(2)
end

print(sqart(4))

morashsPeasant is flipping
Report Abuse
TickerOfTime is not online. TickerOfTime
Joined: 02 Sep 2012
Total Posts: 2030
27 Sep 2015 09:50 PM
@morash
did that with 16, 64, and 128
Got 4, 6, 7
its kinda off
Report Abuse
Xsitsu is online. Xsitsu
Joined: 28 Jul 2009
Total Posts: 2921
27 Sep 2015 09:51 PM
inb4 someone posts the one bit of code from quake whatever number

or maybe they already have. I didn't exactly read the entire thread.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
27 Sep 2015 09:56 PM
loadstring and bytecode, done.
Report Abuse
morash is not online. morash
Joined: 22 May 2010
Total Posts: 5834
27 Sep 2015 10:12 PM
for i,v in pairs (math) do
getfenv()[i] = v
end

print(sqrt(4))

> 2

I win.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
27 Sep 2015 10:25 PM
"return math.log(num)/math.log(2)"
I don't know what made you think that would work, that just gets an exponent required to power 2 to get num...

2^(urcrap) = num
Report Abuse
morashsPeasant is not online. morashsPeasant
Joined: 06 Jan 2011
Total Posts: 4944
27 Sep 2015 10:25 PM
lol morash win, 5k posts!

morashsPeasant is flipping
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
27 Sep 2015 10:26 PM
Also he/she doesn't win, considering he/she still IS using math.sqrt, it's the same function...
Report Abuse
morashsPeasant is not online. morashsPeasant
Joined: 06 Jan 2011
Total Posts: 4944
27 Sep 2015 10:26 PM
@cntkillme
it would be 10^mycrap = aswer
but no exponents (challange)


morashsPeasant is scripting? not even once!
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
27 Sep 2015 10:27 PM
No it wouldn't, it would if you JUST did math.log(num) without the division
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
27 Sep 2015 10:30 PM
Woops I lied, math.log is natural log so it would be e^x, not 10^x
Report Abuse
morashsPeasant is not online. morashsPeasant
Joined: 06 Jan 2011
Total Posts: 4944
27 Sep 2015 10:31 PM
Yep, dang natural logs. There is another function that is log10(blah)
TILua

morashsPeasant is Dermon
Report Abuse
unknownusername97 is not online. unknownusername97
Joined: 20 Jun 2013
Total Posts: 3070
27 Sep 2015 10:31 PM
math.sqrt(x)

#becauseican
Report Abuse
Tynezz is not online. Tynezz
Joined: 28 Apr 2014
Total Posts: 4945
27 Sep 2015 10:35 PM
function sqrt(value)
local count=0
local current=1
while true do
wait()
if current>=value then
break
end
current=current+2
count=count+1
end
return count
end

Maybe
print(sqrt(9))
Report Abuse
lostend is not online. lostend
Joined: 21 Aug 2011
Total Posts: 8265
28 Sep 2015 07:21 AM
^doesnt work; same thing as dividing by 2 except not accurate?

so far, only person that met expectations and did it right is ticker
Report Abuse
GloomDrone is not online. GloomDrone
Joined: 09 Aug 2015
Total Posts: 679
28 Sep 2015 07:28 AM
number = 25

number2 = math.random(0,9e9) --find between 0 and 9 billion

while number2 * number2 ~= number do
print(number2.."x"..number2.."="..number)
end
Report Abuse
GloomDrone is not online. GloomDrone
Joined: 09 Aug 2015
Total Posts: 679
28 Sep 2015 07:30 AM
--woops did something wrong

val = Instance.new("BoolValue")
val.Parent = script

number = 25

number2 = math.random(0,9e9) --find between 0 and 9 billion

while true do
wait()
if number2 * number2 == number and val.Value == false then
print("The square root of "..number.." is "..number2)
val.Value = true
end
end
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