def factorial(n)
if n < 1
raise "argument must be > 0"
elsif n == 1
1
else
n * factorial(n-1)
end
end
def getTimes(type="",ranges="")
if type == "minutes"
times = Time.now + ranges * 60
times = times.strftime("%Y-%m-%d %H:%M:%S")
elsif type == "hours"
times = Time.now + ranges * 60 * 60
times = times.strftime("%Y-%m-%d %H:%M:%S")
elsif type == "days"
times = Time.now + ranges * 24 * 60 * 60
times = times.strftime("%Y-%m-%d %H:%M:%S")
end
return times
end
def bilPrima(maxDeret="")
deret_awal = []
deret_akhir = []
deret_awal = [2, 3, 5]
#Tampung Deret Prima
ii = 2
while ii < maxDeret
deret_akhir[ii] = true
deret_awal.each do |key|
jj = 2 * key.to_i
while jj < maxDeret
deret_akhir[jj] = false
jj += key.to_i
end
end
ii += 1
end
#Print Deret Prima
print "Deret Prima Akhir : "
a = 0
deret_akhir.each do |keys|
if keys == true
print "\n#{a}"
end
a += 1
end
puts "\n"
end
def cetakmenu
loops = 0
while loops < 1
print "<<<<<
Minggu, 30 Mei 2010
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar