Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- object Drugie extends App{
- def palindrom(tab:Array[Int], pocz:Int,kon:Int):Boolean={
- if(pocz==kon)
- return true
- if(tab(pocz)!=tab(kon))
- return false
- return palindrom(tab,pocz+1,kon-1)
- }
- }
- object Czwarte extends App{
- def pierwsza(n: Int): Boolean={
- def pierwszaAcc(n:Int, i:Int):Boolean={
- if(i==n)
- return true;
- if(n%i==0)
- return false;
- return pierwszaAcc(n,i+1)
- }
- pierwszaAcc(n,2)
- }
- var n=io.StdIn.readInt()
- var y:Boolean=pierwsza(n)
- print(y)
- }
- object Piate extends App{
- def ciag(n: Int): Int={
- def ciagAcc(n: Int, a: Int, b: Int):Int ={
- if(n==0 || n==1){
- return b
- }
- ciagAcc(n - 1, b, a + b)
- }
- ciagAcc(n,0,1)
- }
- var n = readInt
- var wynik = ciag(n)
- print(wynik)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement