“rekursive Python” Code-Antworten

Wie die Rekursion in Python funktioniert

def factorial(x):
    """This is a recursive function
    to find the factorial of an integer"""

    if x == 1:
        return 1
    else:
        return (x * factorial(x-1))


num = 1
print("The factorial of", num, "is", factorial(num))
Panicky Penguin

Rekursion in Python

def rec(num):
    if num <= 1:
        return 1
    else:
        return num + rec(num - 1)

print(rec(50))    
Defeated Dunlin

Rekursion Python Beispiele

# Recursive function factorial_recursion()

def factorial_recursion(n):  
   if n == 1:  
       return n  
   else:  
       return n*factorial_recursion(n-1)
Anxious Ape

Was ist Python rekursive Funktion in Python

 pythonCopydef fact(n):
    """Recursive function to find factorial"""
    if n == 1:
        return 1
    else:
        return (n * fact(n - 1))
a = 6
print("Factorial of", a, "=", fact(a))
Shy Skunk

rekursive Python

import random


def guess(a,b):
    x = random.randint(a,b)
    return x


def check(x,y):
    if y ** 2 == x:
        return True
    return False


x = 100
left, right = 0, x
y = guess(left, right)
while not check(x,y):
    y = guess(left, right)
print(y)
Concerned Caterpillar

Ähnliche Antworten wie “rekursive Python”

Fragen ähnlich wie “rekursive Python”

Weitere verwandte Antworten zu “rekursive Python” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen