-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
75 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"files": { | ||
"main.py": [ | ||
{ | ||
"id": "3b53cf6d-bde5-4a6c-a53e-258d8b483d33", | ||
"line": 13, | ||
"version": 209, | ||
"index": 422 | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
language = "python3" | ||
run = "python main.py" | ||
run = ["python3", "weeklyChallenges/week2/factors.py"] |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,3 @@ def menu(banner, options): | |
print(f"Invalid choice: {choice}") | ||
|
||
menu(banner, options) | ||
0 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class factorial: | ||
|
||
def __call__(self, n): | ||
f = 1 | ||
for i in range(1, n + 1): | ||
f = f * i | ||
return f | ||
|
||
|
||
n = int(input("Enter a number:")) | ||
|
||
obj = factorial() | ||
f = obj.__call__(n) | ||
print("Factorial is:", f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
def factors(): | ||
num = int(input("Enter any Number to find its factors: ")) | ||
findFactors(num) | ||
|
||
def findFactors(number): | ||
print("Factors of a Given Number {0} are:".format(number)) | ||
|
||
for value in range(1, number + 1): | ||
if number % value == 0: | ||
print("{0}".format(value), end=" ") | ||
print() | ||
|
||
factors() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class fibonacci: | ||
def __init__(self): | ||
self.fiboSeq = [0, 1] | ||
|
||
def __call__(self, n): | ||
if n < len(self.fiboSeq): | ||
return self.fiboSeq[n] | ||
else: | ||
# Compute the requested Fibonacci number | ||
fib_number = self(n - 1) + self(n - 2) | ||
|
||
#Builds List | ||
self.fiboSeq.append(fib_number) | ||
return self.fiboSeq[n] | ||
|
||
|
||
n = int(input('Type the nth term in the fibonacci sequence: ')) | ||
fibonacci_of = fibonacci() | ||
#Prints nth term that user inputed | ||
print(fibonacci_of(n)) |