Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 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) 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