Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepython
def palindromTest(N):
  if len(N) == 1 or len(N) == 0:
    return True
  else:
    if N[0] == N[-1] and palindromTest(N[1:-1]):
      return True
    else:
      return False

Oppgave 5 -

...

Code Block
languagepython
def minElement(L):
  if len(L) == 1:
    return L[0]
  else:
    min = minElement(L[1:])
    if L[0] < min:
      return L[0]
    else:
      return min

...

Største element

Code Block
languagepython
def maxElement(L):
  if len(L) == 1:
    return L[0]
  else:
    max = maxElement(L[1:])
    if L[0] > max:
      return L[0]
    else
      return max

Oppgave

...

6 - Exponent

Code Block
languagepython
def power(x, n):
  if n < 1:
     return 1
  return x * power(x, n-1)