function f(parameter1, paremeter2) { // define function
argument1 = parameter1; // pass parameters in as arguments
argument2 = parameter2;
return argument1 + argument2;
This file contains hidden or 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
#Problem 12: | |
# The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: | |
# 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... | |
# Let us list the factors of the first seven triangle numbers: | |
# 1: 1 | |
# 3: 1,3 | |
# 6: 1,2,3,6 |
This file contains hidden or 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
$ bundle install | |
Fetching gem metadata from http://rubygems.org/. | |
Error Bundler::HTTPError during request to dependency API | |
Fetching full source index from http://rubygems.org/ | |
^C | |
Quitting... |
This file contains hidden or 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
def guess | |
x = rand(10) | |
puts "I have a number between 0-10 in mind? What is your best guess?" | |
y = gets.chomp!.to_i | |
if x == y | |
print "you got it!" | |
elsif x < y | |
print "You are about #{y-x} too high in your guess.\n" | |
print "Hint, x is #{x}" | |
else x > y |
This file contains hidden or 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
var monthNames = [ | |
"January", "February", "March", "April", "May", "June", | |
"July", "August", "September", "October", "November", "December" | |
]; | |
function onOpen() { | |
var ui = DocumentApp.getUi(); | |
// Or FormApp or SpreadsheetApp. | |
ui.createMenu('Macro') | |
.addItem('Update last modified date', 'replaceFormattedDate') |
OlderNewer