Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Prime-decomposition/Ring/prime-decomposition.ring
Normal file
20
Task/Prime-decomposition/Ring/prime-decomposition.ring
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
prime = 18705
|
||||
decomp(prime)
|
||||
|
||||
func decomp nr
|
||||
x = ""
|
||||
for i = 1 to nr
|
||||
if isPrime(i) and nr % i = 0
|
||||
x = x + string(i) + " * " ok
|
||||
if i = nr
|
||||
x2 = substr(x,1,(len(x)-2))
|
||||
see string(nr) + " = " + x2 + nl ok
|
||||
next
|
||||
|
||||
func isPrime num
|
||||
if (num <= 1) return 0 ok
|
||||
if (num % 2 = 0) and num != 2 return 0 ok
|
||||
for i = 3 to floor(num / 2) -1 step 2
|
||||
if (num % i = 0) return 0 ok
|
||||
next
|
||||
return 1
|
||||
Loading…
Add table
Add a link
Reference in a new issue