1. Given integer n as an input, write a program that determines if n is a power of 2. In this case, print the power value.

    Implement a function func power2(n uint) int, which returns the power value, or -1, if n is not the power of 2.

    Example:

    power2(8) = 3
    
  2. Given integers n and k as an input, write a program that determins if n is a power of k. In this case, print the power value.

    Implement a function func powerK(n, k uint) in, which returns the power value, or -1, if n is not the power of K.

    Example:

    powerK(64, 4) = 3
    
  3. Given integer n as an input, write a program that determines if n is a prime number.

    Implement a function func prime(n uint) uint that returns 0 if the number is not prime, and 1 if it is.

    Example:

    prime(2) = 1
    prime(4) = 0
    
  4. Given integer n as an input, write a program that determines if n is a perfect square, i.e. there exists an integer k, such that $k^2 = N$.

    Implement a function func perfectSquare(n uint) (uint, int). The first value returned from the function is 1 if n is the perfect square and, otherwise, 0. The second value is the square root of n, which is relevant only if n is the square root. In other words, if n is the perfect square, then (1, square root of n) is returned; otherwise, (0, any value) is returned.

    Example:

    perfectSquare(9) = (1, 3)
    perfectSquare(8) = (0, 0)
    
  5. Given integer n as an input, write a program that prints the first digit of n.

    Write a function func firstDigit(n int) int.

    Example:

    firstDigit(2147) = 2
    
  6. Given integer n as an input, write a program that reverses digits in n.

    Write a function func reverseNumber(n uint) uint.

    Example:

    reverseNumber(123)  = 321
    
  7. Given integer n as an input, write a program that determines if all digits in n are even.

    Write a function func allDigitsEven(n int) uint, which returns 1, if all digits are even and, otherwise, 0.

    Example:

    allDigitsEven(2860) = 1
    allDigitsEven(2816) = 0
    
  8. Given integer n and floating point values a, d, where a is the initial term of an arithmetic progression, and d is the common difference of successive members of the arithmetic progression, write a program that calculates the nth term of the arithmetic progression and the sum of the first n terms.

    Write a function func apNthTerm(a float64, d float64, n int) (float64, float64).

    Example:

    apNthTerm(2, 3, 5) = (14, 40)
    
  9. Given two integers x and y, such that 1 <= x, y <= 8, which represent a chess board position, write a program that calculates how many moves can a bishop (♗), a queen (♕) and a knight (♔) make from this position.

    Write three functions func bishopMoves(x, y uint) uint, func queenMoves(x, y uint64) and func knightMoves(x, y uint64).

    Example:

    bishopMoves(1, 1) = 7
    queenMoves(1, 1) = 21
    knightMoves(1, 1) = 2
    
  10. Given four integers x1, y1, x2, y2, where (x1, y1) and (x2, y2) represent two position on a chess board, write a program that calculates whether a bishop (♗), a rook (♖), a knight (♘), a king (♔), and a queen (♕) can make a turn from one position to another.

    Write five functions func canBishopMove(x1, y1, x2, y2 uint) uint, func canRookMove(x1, y1, x2, y2 uint) uint, func canKnightMove(x1, y1, x2, y2 uint) uint, func canKingMove(x1, y1, x2, y2 uint) uint, and func canBQueenMove(x1, y1, x2, y2 uint) uint, which return 1 if the piece can make a turn between the positions, and 0 if it cannot.

    Example:

    canBishopMove(1, 1, 3, 3) = 1
    canRookMove(1, 1, 3, 3) = 0
    canKnightMove(1, 1, 3, 3) = 0
    canKingMove(1, 1, 3, 3) = 0
    canQueenMove(1, 1, 3, 3) = 1