SHARE
TWEET

sum range

DulcetAirman Jun 13th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fun main(args: Array<String>) {
  2.     println(sum(100,1000))
  3. }
  4.  
  5. fun sum(begin:Int, end:Int):Int {
  6.     if(begin > end) throw IllegalArgumentException("'begin' must not be greater than 'end'")
  7.     if(begin == end) return end
  8.     return begin + sum(begin+1, end)
  9. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top