Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdded a solution for Project Euler Problem 203 "Squarefree Binomial Coefficients" #3513
Conversation
| coefficients = set() | ||
| previous_coefficients = [] | ||
| for step in range(1, depth + 1): | ||
| if step == 1: | ||
| coefficients.add(1) | ||
| previous_coefficients = [1] | ||
| else: | ||
| coefficients_begins_one = previous_coefficients + [0] | ||
| coefficients_ends_one = [0] + previous_coefficients | ||
| previous_coefficients = [] |
dhruvmanila
Oct 19, 2020
Member
| coefficients = set() | |
| previous_coefficients = [] | |
| for step in range(1, depth + 1): | |
| if step == 1: | |
| coefficients.add(1) | |
| previous_coefficients = [1] | |
| else: | |
| coefficients_begins_one = previous_coefficients + [0] | |
| coefficients_ends_one = [0] + previous_coefficients | |
| previous_coefficients = [] | |
| coefficients = {1} | |
| previous_coefficients = [1] | |
| for step in range(2, depth + 1): | |
| coefficients_begins_one = previous_coefficients + [0] | |
| coefficients_ends_one = [0] + previous_coefficients | |
| previous_coefficients = [] |
Please test whether this works or not.
fernandobperezm
Oct 19, 2020
•
Author
Tested locally and works. Also black, flake8 and doctests pass. Commit is already on the branch :-D
…ngle. Changes based on review suggestion.
Describe your change:
Added a solution to Project Euler Problem 203 "Squarefree Binomial Coefficients" Link.
The solution is based on three main pilars.
d.2and the maximum coefficientCmaxusing a variant of the Sieve of Eratosthenes Link and considering that the square of each prime must be less or equal than thatCmax. The calculation returns the square of those primes.ninton = p * p * rwherepis a prime number calculated before andris a positive integer. If norcan be found for all squared primes, then the number is squarefree, else, the number is non-squarefree.After all unique squarefree numbers are calculated, they're summed-up to provide the final answer.
Checklist:
Fixes: #{$ISSUE_NO}.