Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Triangle de pascal :
- def pascal(c: Int, r: Int): Int = {
- if ( c > r )
- throw new java.lang.IllegalArgumentException("c > r")
- else if ( c < 0 )
- throw new java.lang.IllegalArgumentException("c < 0")
- else if ( r < 0 )
- throw new java.lang.IllegalArgumentException("r < 0")
- else if ( c==0 || r==c )
- 1
- else
- pascal(c, r-1) + pascal(c-1, r-1)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement