Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.91 KB | None | 0 0
  1. object Drugie extends App{
  2.  def palindrom(tab:Array[Int], pocz:Int,kon:Int):Boolean={
  3.         if(pocz==kon)
  4.             return true
  5.         if(tab(pocz)!=tab(kon))
  6.             return false
  7.         return palindrom(tab,pocz+1,kon-1)
  8.     }
  9. }
  10.  
  11.  
  12. object Czwarte extends App{
  13.     def pierwsza(n: Int): Boolean={
  14.         def pierwszaAcc(n:Int, i:Int):Boolean={
  15.             if(i==n)
  16.                 return true;
  17.             if(n%i==0)
  18.                 return false;
  19.             return pierwszaAcc(n,i+1)
  20.         }
  21.         pierwszaAcc(n,2)
  22.     }
  23.     var n=io.StdIn.readInt()
  24.     var y:Boolean=pierwsza(n)
  25.     print(y)
  26. }
  27.  
  28.  
  29. object Piate extends App{
  30. def ciag(n: Int): Int={
  31.     def ciagAcc(n: Int, a: Int, b: Int):Int ={
  32.         if(n==0 || n==1){
  33.             return b
  34.         }
  35.         ciagAcc(n - 1, b, a + b)
  36.     }
  37.     ciagAcc(n,0,1)
  38. }
  39. var n = readInt
  40. var wynik = ciag(n)
  41. print(wynik)
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement