from math import sqrt def primemaker(x): if x < 2: return [] else: primes = [2] for possible_prime in range(3, x+1, 2): #check only odd numbers limit = sqrt(possible_prime) for prime in primes: if prime > limit: primes.append(possible_prime) break if 0 == possible_prime % prime: break return primes
- from math import sqrt
- def primemaker(x):
- if x < 2:
- return []
- else:
- primes = [2]
for possible_prime in range(3, x+1, 2): # check only odd numbers- for possible_prime in range(3, x+1, 2): #check only odd numbers
- limit = sqrt(possible_prime)
- for prime in primes:
- if prime > limit:
- primes.append(possible_prime)
- break
- if 0 == possible_prime % prime:
- break
- return primes
just trying how this works
public func holabro(){
a=1
return ""
}
import XCTest
// XCTest Spec Example:
// TODO: replace with your own tests (TDD), these are just how-to examples to get you started
class SolutionTest: XCTestCase {
static var allTests = [
("Test Example", testExample),
]
func testExample() {
let actual = 1
XCTAssertEqual(actual, 1)
}
}
XCTMain([
testCase(SolutionTest.allTests)
])
from math import sqrt def primemaker(x): primes = [] if x < 2: return [] else: primes.append(2) for possible_prime in range(3,(x+1), 2): #only odd numbers limit = sqrt(possible_prime) for prime in primes: if prime > limit: primes.append(possible_prime) break if 0 == possible_prime % prime: break return primes
- from math import sqrt
- def primemaker(x):
- primes = []
- if x < 2:
- return []
- else:
- primes.append(2)
for possible_prime in range(3,(x+1), 2): # only odd numbers- for possible_prime in range(3,(x+1), 2): #only odd numbers
- limit = sqrt(possible_prime)
- for prime in primes:
- if prime > limit:
- primes.append(possible_prime)
- break
- if 0 == possible_prime % prime:
- break
- return primes