This file contains hidden or 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
| #!/usr/local/bin/node | |
| // calculate the decimal to 1MM places, but record certain values | |
| string = ""; | |
| for (i=1;i<=1000000;i++) | |
| { | |
| string += i.toString() | |
| } |
This file contains hidden or 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
| #!/usr/local/bin/node | |
| // first, prep prime seive up to 7654321, which is the largest pan that doesn't fail the | |
| // summing divisibility rules for 3 or 9 | |
| n=7654321; | |
| myPrimes = new Array(); | |
| for (i=2;i<=n;i++) | |
| { | |
| myPrimes[i]=true; |
This file contains hidden or 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
| #!/usr/local/bin/node | |
| words = ["A","ABILITY","ABLE","ABOUT","ABOVE","ABSENCE","ABSOLUTELY","ACADEMIC","ACCEPT","ACCESS","ACCIDENT","ACCOMPANY","ACCORDING","ACCOUNT","ACHIEVE","ACHIEVEMENT","ACID","ACQUIRE","ACROSS","ACT","ACTION","ACTIVE","ACTIVITY","ACTUAL","ACTUALLY","ADD","ADDITION","ADDITIONAL","ADDRESS","ADMINISTRATION","ADMIT","ADOPT","ADULT","ADVANCE","ADVANTAGE","ADVICE","ADVISE","AFFAIR","AFFECT","AFFORD","AFRAID","AFTER","AFTERNOON","AFTERWARDS","AGAIN","AGAINST","AGE","AGENCY","AGENT","AGO","AGREE","AGREEMENT","AHEAD","AID","AIM","AIR","AIRCRAFT","ALL","ALLOW","ALMOST","ALONE","ALONG","ALREADY","ALRIGHT","ALSO","ALTERNATIVE","ALTHOUGH","ALWAYS","AMONG","AMONGST","AMOUNT","AN","ANALYSIS","ANCIENT","AND","ANIMAL","ANNOUNCE","ANNUAL","ANOTHER","ANSWER","ANY","ANYBODY","ANYONE","ANYTHING","ANYWAY","APART","APPARENT","APPARENTLY","APPEAL","APPEAR","APPEARANCE","APPLICATION","APPLY","APPOINT","APPOINTMENT","APPROACH","APPROPRIATE","APPROVE","AREA","ARGUE","ARGUMENT","ARISE","ARM","ARMY","AROUND","ARRANG |
This file contains hidden or 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
| # let's try using the built in permutation function! | |
| import itertools | |
| x = itertools.permutations('0123456789', 10) | |
| sum = 0 | |
| for i in x: | |
| string= "".join(list(i)) | |
| number = int(string) |
This file contains hidden or 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
| # let's start by making a set of all pentagonal numbers from to n=10000 | |
| # you can actually do to like n=4000 and get the same answer | |
| # then let's say check every number in set vs. every other. | |
| # if sum and difference is also in the set, compute the difference, print | |
| h = set() | |
| for i in range (1,10000): | |
| pent = (i*(3*i-1))/2 | |
| h.add(pent) |
This file contains hidden or 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
| # we'll store numbers in two sets and keep going until we get a match | |
| i = 286 | |
| found = False | |
| p = set() | |
| h = set() | |
| while found == False: | |
| hex = (i*(2*i-1)) | |
| h.add(hex) |
This file contains hidden or 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
| # set up prime seive | |
| n=10000 | |
| myPrimes = [] | |
| myPrimes = [True]*10001 | |
| myPrimes[0] = False | |
| myPrimes[1] = False | |
| for i in range (2,n): | |
| if myPrimes[i] == True: | |
| j = 2*i | |
| while j<=n: |
This file contains hidden or 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
| # set up 2 sieves- one is erastosthenes, the other is to track count | |
| n=200000 | |
| myPrimes = [True]*(n+1) | |
| myCount = [0]*(n+1) | |
| # sieve, but count each time each composite number is hit during sieve | |
| for i in range (2,n): | |
| if myPrimes[i] == True: | |
| j = 2*i | |
| while j<=n: |
This file contains hidden or 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
| # http://projecteuler.net/problem=48. | |
| n = 1000 | |
| sum = 0 | |
| for i in range (1,n+1): | |
| sum += i**i | |
| print str(sum)[-10:] | |
| # python makes this trivial- but for a language that can't deal with large numbers, |
This file contains hidden or 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
| # http://projecteuler.net/problem=49 | |
| # we'll use the python built-in permutation function | |
| import itertools | |
| # prime sieve | |
| n=100000 | |
| myPrimes = [True]*(n+1) | |
| for i in range (2,n): | |
| if myPrimes[i] == True: |