Guest User

Untitled

a guest
Jan 17th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. count(r,c,1,0)
  2.  
  3. def count(r: Int, c: Int, countR: Int, lalaCount: Int): Int = {
  4. if (countR < (r + 1)) count(r,c,countR + 1, lalaCount + countR)
  5. else (lalaCount + c + 1)
  6. }
  7.  
  8. object hw1 {
  9. def pascal(c: Int, r: Int): Int = {
  10.  
  11. count(r,c,1,0)
  12.  
  13. def count(r: Int, c: Int, countR: Int, lalaCount: Int): Int = {
  14. if (countR < (r + 1)) count(r,c,countR + 1, lalaCount + countR)
  15. else (lalaCount + c + 1)
  16. }
  17. } //On this line eclipse is saying "Multiple markers at this line
  18. //- type mismatch; found : Unit required: Int
  19. //- type mismatch; found : Unit required: Int
  20. pascal(3,4)
  21.  
  22. def pascal(c: Int, r: Int): Int = {
  23.  
  24. count(r,c,1,0) // => Int
  25.  
  26. def count(r: Int, c: Int, countR: Int, lalaCount: Int): Int = {
  27. if (countR < (r + 1)) count(r,c,countR + 1, lalaCount + countR)
  28. else (lalaCount + c + 1)
  29. } // => Unit
  30. }
Add Comment
Please, Sign In to add comment