brewersfan1976

count_sum_of_two_representations2.rb

Mar 29th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.29 KB | None | 0 0
  1. def countSumOfTwoRepresentations2(n, l, r)
  2.     result = 0
  3.     a = l
  4.    
  5.     while (a <= r)
  6.           b = n - a
  7.        
  8.           if b >= 1 && b <= r && b >= a then
  9.              result = result + 1
  10.           end
  11.              
  12.           a = a + 1
  13.     end
  14.        
  15.     return result
  16. end
Advertisement
Add Comment
Please, Sign In to add comment