Welcome! This page is using CodeRay 1.1.2.

We currently have 3055 rays in the database.
You can add a New Ray or browse the posted rays by pages.

Page 116, 10 entries

asdsa 9 lines of Ruby by asda 132 Bytes Show Edit Expand
1
2
3
4
5
6
7
8
9
E=Math.exp(1)
def intk(k)
  return k<1 ? 1-E**(-1) : k*intk(k-1)-E**(-1)
end

25.times  { |i|
  z=intk(i)
  puts "#{i}: #{z}"
}
asdsa 5 lines of Ruby by asda 81 Bytes Show Edit Expand
1
2
3
4
5
t=0.1
for n in 1..30
  e=n/10.0-0.1*n
  puts "#{n}\t #{n.to_s(2)}\t #{e}"
end
zcffs 14 lines of Ruby by asdfds 511 Bytes Show Edit Expand
1
2
3
4
5
6
7
E=Math.exp(1)
s=[10,100,1000]
puts "ex-e-x/ex+e-x:"
s.sort.each{ |x| puts (E**(x)-E**(-x))/(E**(x)+E**(-x)) }
puts "\ne2x-1/e2x+1:"
s.sort.each{ |x| puts (E**(2*x)-1)/(E**(2*x)+1) }
puts "\n1...
test 1 line of diff 19 Bytes Show Edit Expand
1
sudo chmod -R 775 *
MN1 20 lines of Ruby 208 Bytes Show Edit Expand
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

julia> function scnd(t)
for n=1:10
e=n/10-n*t
println(e)
end
end

julia>
julia> scnd(0.1)
0.0
0.0
-5.551115123125783e-17
0.0
0.0
-1.1102230246251565e-16
-1.1102230246251565e-16
0....
MN1 15 lines of Ruby 171 Bytes Show Edit Expand
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
julia> function firs(x)
y=(e^x-e^(-x))/(e^x+e^(-x))
end

julia>
julia> firs(10)
0.9999999958776926

julia>
julia> firs(100)
1.0

julia>
julia> firs(1000)
NaN
ApaLab1 9 lines of Ruby 227 Bytes Show Edit Expand
1
2
3
4
5
6
7
8
9
For:                     Time:
Fib1(35)                 2.309
Fib2(200000)             2.090
Fib3(4000000)            2.434

For:                     Time:
Fib1(40)                 25.366
Fib2(400000)             8.019
...
asda 56 lines of Ruby by asda 681 Bytes Show Edit Expand
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'benchmark'

def fib1(n)
return n<2 ? n : fib1(n-1)+fib1(n-2)
end


def fib2(n)
  i=1
  j=0
  n.times {
    j=i+j
    i=j-i
  }
  return j
end


def fib3(n)
  i=1
  j=0
  k=0
  h=1...
asda 59 lines of Ruby by asda 747 Bytes Show Edit Expand
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require 'benchmark'

def fib1(n)
  #return n<2 ? n : fib1(n-1)+fib1(n-2)
  if n<2 then return n
  else return  fib1(n-1)+fib1(n-2)
  end
end


def fib2(n)
  i=1
  j=0
  n.times {
    j=i+j
    ...
Frozen symbols 9 lines of Ruby 171 Bytes Show Edit Expand
1
2
3
4
5
6
7
8
9
irb(main):001:0> :foo
=> :foo
irb(main):002:0> :foo.frozen?
=> false
irb(main):003:0> :foo.freeze
=> :foo
irb(main):004:0> :foo.frozen?
=> true
irb(main):005:0> 

Page 116, 10 entries