-
Notifications
You must be signed in to change notification settings - Fork 352
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
1 parent
e32f66c
commit 63c03e1
Showing
5 changed files
with
68 additions
and
0 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 @@ | ||
'''Finding factors of a number''' | ||
import math | ||
|
||
n=int(input()) | ||
|
||
l=[] | ||
|
||
for i in range(1,int(math.sqrt(n))+1): | ||
if(n%i==0): | ||
l.append(i) | ||
|
||
print(l) |
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,15 @@ | ||
''' | ||
Find the larger number n greater than n2 that is divisible by n1. | ||
For eg: | ||
4 7 | ||
output: 8 | ||
since 8 is the nearest larger number than 7 and it is divisible by 4. | ||
''' | ||
|
||
|
||
mn=input().split() | ||
|
||
m=int(mn[0]) | ||
n=int(mn[1]) | ||
|
||
print(((n//m)+1)*m) |
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,9 @@ | ||
'''Program to find the factorial of a number using recursion''' | ||
|
||
#Taking number from user and finding its factorial using loop | ||
n = int(input()) | ||
fact=1 | ||
for i in range(1,n+1): | ||
fact*=i | ||
|
||
print(fact) |
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 @@ | ||
'''Program to find the factorial of a number using recursion''' | ||
|
||
def factorial_of_a_number(n): | ||
if n<=1: | ||
return 1 | ||
else: | ||
return n * factorial_of_a_number(n-1) | ||
|
||
#Taking number from user and passing it to the function | ||
|
||
n = int(input()) | ||
print(factorial_of_a_number(n)) |
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 @@ | ||
'''Fibonacci series upto n value''' | ||
|
||
# taking user input-1 | ||
n = int(input()) | ||
|
||
a=0 | ||
b=1 | ||
|
||
if(a<=n): | ||
print(a," ",end="") | ||
if(b<=n): | ||
print(b," ",end="") | ||
c=a+b | ||
while(c<=n): | ||
print(c," ",end="") | ||
a=b | ||
b=c | ||
c=a+b | ||
else: | ||
print("None of the values in fibonacci series are less than",n) |