Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
list of primes
#python 3.5.2 def prime(n): i = 2 j = 0 while i*i <= n and j != 1: if n%i == 0: j = 1 break i += 1 if j == 1: f = 0 else: f = 1 return f def powmod(x, n, module): result = 1 while n != 0: if n % 2 != 0: result *= x result %= module n -= 1 else: x *= x x %= module n /= 2 return result def numberofzeros(a,o): i = 1 j = 0 while ((i < o) and (j<2)): if (powmod(2,a,i)==powmod(a,3,i)): j += 1 i += 1 return j def primetest(q): r = 0 a = 2 while (a<q*q) : if ((powmod(2,a,q)==powmod(a,3,q)) and (numberofzeros(a,q)==1)) : r = 1 break a += 1 return r def list(o): cnt = 0 zcnt = 0 i = 2 while i < o: if (primetest(i)==1): print(str(i)+' a prime') cnt = cnt+1 if (prime(i)==1): print(str(i)+' a prime') zcnt = zcnt+1 i+=1 print(str(cnt-zcnt)+' errors') list(2**6)
run
|
edit
|
history
|
help
0
Regular falsi
("Hello,world!")
Linked list pnkj 845
Merge sort implementation
Hi.py
Pawan 1
Python3 complete func.
shuru9
Moore Voting Algorithm
fibonacciseries