-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
- Loading branch information
Showing
81 changed files
with
13,317 additions
and
13,317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
def ack(m, n) | ||
if m == 0 then | ||
n + 1 | ||
elsif n == 0 then | ||
ack(m - 1, 1) | ||
else | ||
ack(m - 1, ack(m, n - 1)) | ||
end | ||
end | ||
|
||
def the_answer_to_life_the_universe_and_everything | ||
(ack(3,7).to_s.split(//).inject(0){|s,x| s+x.to_i}.to_s + "2" ).to_i | ||
end | ||
|
||
answer = the_answer_to_life_the_universe_and_everything | ||
def ack(m, n) | ||
if m == 0 then | ||
n + 1 | ||
elsif n == 0 then | ||
ack(m - 1, 1) | ||
else | ||
ack(m - 1, ack(m, n - 1)) | ||
end | ||
end | ||
|
||
def the_answer_to_life_the_universe_and_everything | ||
(ack(3,7).to_s.split(//).inject(0){|s,x| s+x.to_i}.to_s + "2" ).to_i | ||
end | ||
|
||
answer = the_answer_to_life_the_universe_and_everything |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
def fact(n) | ||
if(n > 1) | ||
n * fact(n-1) | ||
else | ||
1 | ||
end | ||
end | ||
|
||
8.times{ | ||
fact(5000) | ||
def fact(n) | ||
if(n > 1) | ||
n * fact(n-1) | ||
else | ||
1 | ||
end | ||
end | ||
|
||
8.times{ | ||
fact(5000) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
def fib n | ||
if n < 3 | ||
1 | ||
else | ||
fib(n-1) + fib(n-2) | ||
end | ||
end | ||
|
||
fib(34) | ||
def fib n | ||
if n < 3 | ||
1 | ||
else | ||
fib(n-1) + fib(n-2) | ||
end | ||
end | ||
|
||
fib(34) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
require 'complex' | ||
|
||
def mandelbrot? z | ||
i = 0 | ||
while i<100 | ||
i+=1 | ||
z = z * z | ||
return false if z.abs > 2 | ||
end | ||
true | ||
end | ||
|
||
ary = [] | ||
|
||
(0..100).each{|dx| | ||
(0..100).each{|dy| | ||
x = dx / 50.0 | ||
y = dy / 50.0 | ||
c = Complex(x, y) | ||
ary << c if mandelbrot?(c) | ||
} | ||
} | ||
require 'complex' | ||
|
||
def mandelbrot? z | ||
i = 0 | ||
while i<100 | ||
i+=1 | ||
z = z * z | ||
return false if z.abs > 2 | ||
end | ||
true | ||
end | ||
|
||
ary = [] | ||
|
||
(0..100).each{|dx| | ||
(0..100).each{|dy| | ||
x = dx / 50.0 | ||
y = dy / 50.0 | ||
c = Complex(x, y) | ||
ary << c if mandelbrot?(c) | ||
} | ||
} | ||
|
Oops, something went wrong.