The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
tim
Posted by: ioni | April 18, 2010 @ 5:20pm
Python Code
[
Download
]
import math from math import * def p12e(int1): # i and tri are for advancing the triangular number i = 1 tri = 1 factors = 1 # loop until there are more than int1 factors while factors <= int1: factors = 1 ########## # Calculate the number of factors that tri has. prime = 1 temp = tri # STOP WHEN PRIME IS BIGGER THAN TRIANGLE: t = 1 while temp % 2 == 0: temp = temp / 2 t += 1 factors *= t t = 1 while temp % 3 == 0: temp = temp / 3 t += 1 factors *= t ########## while prime <= tri: prime = prime + 2 # DIVIDE AS MANY TIMES AS POSSIBLE t = 1 while temp % prime == 0: temp = temp / prime t += 1 factors *= t ########## # keep together i += 1 tri += i # when done, what is the triangle number that meets requirements? return tri - i
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.56 / 8
50 Votes
http://codebin.yi.org/595
page generated in 0.01 seconds