Skip to content

Instantly share code, notes, and snippets.

@keitheous
Created August 6, 2016 00:39
Show Gist options
  • Save keitheous/95728bda8d9b5d626c4590c0cd29623a to your computer and use it in GitHub Desktop.
Save keitheous/95728bda8d9b5d626c4590c0cd29623a to your computer and use it in GitHub Desktop.
require 'pry'
class Squares
def initialize(num)
@num = num
end
def square_of_sum
square_of_sum = 0
(1..@num).each do |i|
square_of_sum += i
end
@square_of_sum = square_of_sum**2
end
def sum_of_squares
sum_of_squares = 0
(1..@num).each do |i|
sum_of_squares += i**2
end
@sum_of_squares = sum_of_squares
end
def difference
difference = @square_of_sum - @sum_of_squares
#? what do i do here to call second & third function first before this function
end
end
# Squares.new(5).square_of_sum
@keitheous
Copy link
Author

def test_difference_of_squares_0
# skip
assert_equal 0, Squares.new(0).difference
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment