Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.47 KB | None | 0 0
  1. # setting variables
  2. a=0
  3. i=0
  4. z=3
  5. x=5
  6. f=0
  7. b=0
  8. loop do #start loop
  9.    i+=1 # i = i + 1
  10.    if i >=1000 # if is 1000 or is greater than 1000
  11.       break # then break loop
  12.    elsif (i%z)==0 # otherwise, if i is divisible by 3, a = a + i
  13.       a=a+i
  14. #      p a
  15.    else # else,
  16.       next #repeat loop
  17.    end
  18. end
  19.  
  20. loop do
  21.    f+=1
  22.    if f>=1000
  23.       break
  24.    elsif (f%x)==0
  25.       b=b+f
  26. #      p b
  27.    else
  28.       next
  29.    end  
  30. end
  31.  
  32. #a=a-i
  33. #b=b-f
  34. p a
  35. p b
  36. p a+b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement