Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
42
Task/Self-numbers/Ring/self-numbers.ring
Normal file
42
Task/Self-numbers/Ring/self-numbers.ring
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
load "stdlib.ring"
|
||||
|
||||
see "working..." + nl
|
||||
see "The first 50 self numbers are:" + nl
|
||||
|
||||
n = 0
|
||||
num = 0
|
||||
limit = 51
|
||||
limit2 = 10000000
|
||||
|
||||
while true
|
||||
n = n + 1
|
||||
for m = 1 to n
|
||||
flag = 1
|
||||
sum = 0
|
||||
strnum = string(m)
|
||||
for p = 1 to len(strnum)
|
||||
sum = sum + number(strnum[p])
|
||||
next
|
||||
sum2 = m + sum
|
||||
if sum2 = n
|
||||
flag = 0
|
||||
exit
|
||||
else
|
||||
flag = 1
|
||||
ok
|
||||
next
|
||||
if flag = 1
|
||||
num = num + 1
|
||||
if num < limit
|
||||
see "" + num + ". " + n + nl
|
||||
ok
|
||||
if num = limit2
|
||||
see "The " + limit2 + "th self number is: " + n + nl
|
||||
ok
|
||||
if num > limit2
|
||||
exit
|
||||
ok
|
||||
ok
|
||||
end
|
||||
|
||||
see "done..." + nl
|
||||
Loading…
Add table
Add a link
Reference in a new issue