Advertisement
FrozenFly

PertemuanKeempat Function

Dec 13th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.50 KB | None | 0 0
  1. /*
  2.     1. Function
  3.  
  4.     f(x) = x*x + 2x +3
  5.  
  6.     f(1) = 1*1 + 2*1 + 3
  7.  
  8.     f(1) = 6
  9.  
  10.     f2(x, y) = x*x + 2y + 3
  11.  
  12.     f2(1, 2) =
  13.  
  14.     fun nama_function (parameter) {
  15.         //statement
  16.     }
  17.  */
  18.  
  19. fun f ( x : Int ) {
  20.     val rumus = x*x + 2*x + 3
  21.     println(rumus)
  22. }
  23.  
  24. fun f2 ( x : Int, y : Int ) {
  25.     val rumus = x*x + 2*y + 3
  26.     println(rumus)
  27. }
  28.  
  29. fun main(){
  30.     f(1)
  31.     f(2)
  32.     f(3)
  33.     f(4)
  34.     f(5)
  35.     f(6)
  36.     f(7)
  37.     f(8)
  38.     f(9)
  39.     f(10)
  40.  
  41.     f2(1, 2)
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement