diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/3-1.py | 14 | ||||
-rw-r--r-- | test/3-2.py | 16 | ||||
-rw-r--r-- | test/3-3.py | 8 | ||||
-rw-r--r-- | test/3-4.py | 8 |
4 files changed, 46 insertions, 0 deletions
diff --git a/test/3-1.py b/test/3-1.py new file mode 100644 index 0000000..95d2fbe --- /dev/null +++ b/test/3-1.py @@ -0,0 +1,14 @@ + +def prime_num(num, div): + if (num >=1): + if (div*div <= num/2): + if (num % div) == 0: + return False + else: + return prime_num(num,div+1) + else: + return True + else: + return False + +print(prime_num(29,2)) diff --git a/test/3-2.py b/test/3-2.py new file mode 100644 index 0000000..417fbde --- /dev/null +++ b/test/3-2.py @@ -0,0 +1,16 @@ + +num = 29 + +def prime_numBIS(div): + if (num >=1): + if (div*div <= num/2): + if (num % div) == 0: + return False + else: + return prime_numBIS(div+1) + else: + return True + else: + return False + +print(prime_numBIS(2)) diff --git a/test/3-3.py b/test/3-3.py new file mode 100644 index 0000000..af57e46 --- /dev/null +++ b/test/3-3.py @@ -0,0 +1,8 @@ + +def fibonacci(n): + if ((n == 0) or (n == 1)): + return 1 + else: + return (fibonacci(n-1) + fibonacci(n-2)) + +print(fibonacci(6)) diff --git a/test/3-4.py b/test/3-4.py new file mode 100644 index 0000000..79bf77a --- /dev/null +++ b/test/3-4.py @@ -0,0 +1,8 @@ + +def fibonacciIT(n,a,b): + if ((n == 0) or (n == 1)): + return a + else: + return (fibonacciIT(n-1, a+b, a)) + +print(fibonacciIT(6,1,1)) |