all valid python 3

This commit is contained in:
Alex Brown
2018-10-20 14:45:08 -05:00
parent b566055e4b
commit ea2ddaaf6a
37 changed files with 76 additions and 1436 deletions

View File

@ -7,7 +7,7 @@ By considering the terms in the Fibonacci sequence whose values do not exceed n,
e.g. for n=10, we have {2,8}, sum is 10.
'''
"""Python 3"""
n = int(raw_input())
n = int(input())
a=0
b=2
count=0

View File

@ -19,7 +19,7 @@ def isprime(no):
return True
maxNumber = 0
n=int(raw_input())
n=int(input())
if(isprime(n)):
print(n)
else:

View File

@ -4,7 +4,7 @@ The prime factors of 13195 are 5,7,13 and 29. What is the largest prime factor o
e.g. for 10, largest prime factor = 5. For 17, largest prime factor = 17.
'''
from __future__ import print_function
n=int(raw_input())
n=int(input())
prime=1
i=2
while(i*i<=n):

View File

@ -4,7 +4,7 @@ A palindromic number reads the same both ways. The largest palindrome made from
Find the largest palindrome made from the product of two 3-digit numbers which is less than N.
'''
from __future__ import print_function
limit = int(raw_input("limit? "))
limit = int(input("limit? "))
# fetchs the next number
for number in range(limit-1,10000,-1):
@ -26,4 +26,4 @@ for number in range(limit-1,10000,-1):
print(number)
exit(0)
divisor -=1
divisor -=1

View File

@ -12,8 +12,8 @@ for i in range(999,100,-1):
arr.append(i*j)
arr.sort()
n=int(raw_input())
n=int(input())
for i in arr[::-1]:
if(i<n):
print(i)
exit(0)
exit(0)

View File

@ -5,7 +5,7 @@ What is the smallest positive number that is evenly divisible(divisible with no
'''
from __future__ import print_function
n = int(raw_input())
n = int(input())
i = 0
while 1:
i+=n*(n-1)
@ -18,4 +18,4 @@ while 1:
if(i==0):
i=1
print(i)
break
break

View File

@ -13,7 +13,7 @@ def gcd(x,y):
def lcm(x,y):
return (x*y)//gcd(x,y)
n = int(raw_input())
n = int(input())
g=1
for i in range(1,n+1):
g=lcm(g,i)

View File

@ -12,9 +12,9 @@ from __future__ import print_function
suma = 0
sumb = 0
n = int(raw_input())
n = int(input())
for i in range(1,n+1):
suma += i**2
sumb += i
sum = sumb**2 - suma
print(sum)
print(sum)

View File

@ -9,8 +9,8 @@ Hence the difference between the sum of the squares of the first ten natural num
Find the difference between the sum of the squares of the first N natural numbers and the square of the sum.
'''
from __future__ import print_function
n = int(raw_input())
n = int(input())
suma = n*(n+1)/2
suma **= 2
sumb = n*(n+1)*(2*n+1)/6
print(suma-sumb)
print(suma-sumb)

View File

@ -16,7 +16,7 @@ def isprime(n):
if(n%i==0):
return False
return True
n = int(raw_input())
n = int(input())
i=0
j=1
while(i!=n and j<3):
@ -27,4 +27,4 @@ while(i!=n):
j+=2
if(isprime(j)):
i+=1
print(j)
print(j)

View File

@ -4,7 +4,7 @@ def isprime(number):
if number%i==0:
return False
return True
n = int(raw_input('Enter The N\'th Prime Number You Want To Get: ')) # Ask For The N'th Prime Number Wanted
n = int(input('Enter The N\'th Prime Number You Want To Get: ')) # Ask For The N'th Prime Number Wanted
primes = []
num = 2
while len(primes) < n:

View File

@ -1,7 +1,7 @@
import sys
def main():
LargestProduct = -sys.maxsize-1
number=raw_input().strip()
number=input().strip()
for i in range(len(number)-13):
product=1
for j in range(13):

View File

@ -6,7 +6,7 @@ Find maximum possible value of product of a,b,c among all such Pythagorean tripl
product=-1
d=0
N = int(raw_input())
N = int(input())
for a in range(1,N//3):
"""Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c """
b=(N*N-2*a*N)//(2*N-2*a)

View File

@ -4,11 +4,11 @@ Work out the first ten digits of the sum of the N 50-digit numbers.
'''
from __future__ import print_function
n = int(raw_input().strip())
n = int(input().strip())
array = []
for i in range(n):
array.append(int(raw_input().strip()))
array.append(int(input().strip()))
print(str(sum(array))[:10])

View File

@ -1,4 +1,4 @@
power = int(raw_input("Enter the power of 2: "))
power = int(input("Enter the power of 2: "))
num = 2**power
string_num = str(num)

View File

@ -15,7 +15,7 @@ def split_and_add(number):
return sum_of_digits
# Taking the user input.
number = int(raw_input("Enter the Number: "))
number = int(input("Enter the Number: "))
# Assigning the factorial from the factorial function.
factorial = factorial(number)