Skip to content

Instantly share code, notes, and snippets.

@hiddenpower
Created April 25, 2013 15:43
Show Gist options
  • Save hiddenpower/5460741 to your computer and use it in GitHub Desktop.
Save hiddenpower/5460741 to your computer and use it in GitHub Desktop.
1.- Cantidad de sumas no repetidas que forman un entero 2.- Obtencion de cubos mediante suma de impares
def sumas(n)
a = n
result = 0
for i in 0..n
if i <= a
result += 1
a -= 1
end
end
result
end
sumas(5)
def cubo(n)
i=1
answer = 0
start = (n*n)-(n-1)
while i <= n
answer += start
start = start + 2
i+=1
end
answer
end
cubo(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment