Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
51
Task/Smith-numbers/Action-/smith-numbers.action
Normal file
51
Task/Smith-numbers/Action-/smith-numbers.action
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
CARD FUNC SumDigits(CARD n)
|
||||
CARD res,a
|
||||
|
||||
res=0
|
||||
WHILE n#0
|
||||
DO
|
||||
res==+n MOD 10
|
||||
n==/10
|
||||
OD
|
||||
RETURN (res)
|
||||
|
||||
CARD FUNC PrimeFactors(CARD n CARD ARRAY f)
|
||||
CARD a,count
|
||||
|
||||
a=2 count=0
|
||||
DO
|
||||
IF n MOD a=0 THEN
|
||||
f(count)=a
|
||||
count==+1
|
||||
n==/a
|
||||
IF n=1 THEN
|
||||
RETURN (count)
|
||||
FI
|
||||
ELSE
|
||||
a==+1
|
||||
FI
|
||||
OD
|
||||
RETURN (0)
|
||||
|
||||
PROC Main()
|
||||
CARD n,i,s1,s2,count,tmp
|
||||
CARD ARRAY f(100)
|
||||
|
||||
FOR n=4 TO 10000
|
||||
DO
|
||||
count=PrimeFactors(n,f)
|
||||
IF count>=2 THEN
|
||||
s1=SumDigits(n)
|
||||
s2=0
|
||||
FOR i=0 TO count-1
|
||||
DO
|
||||
tmp=f(i)
|
||||
s2==+SumDigits(tmp)
|
||||
OD
|
||||
IF s1=s2 THEN
|
||||
PrintC(n) Put(32)
|
||||
FI
|
||||
FI
|
||||
Poke(77,0) ;turn off the attract mode
|
||||
OD
|
||||
RETURN
|
||||
Loading…
Add table
Add a link
Reference in a new issue