Data update
This commit is contained in:
parent
aec8ed51b6
commit
29a5eea0d4
128 changed files with 1298 additions and 0 deletions
36
Task/Smith-numbers/ABC/smith-numbers.abc
Normal file
36
Task/Smith-numbers/ABC/smith-numbers.abc
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
HOW TO RETURN factors n:
|
||||
PUT {} IN factors
|
||||
PUT 2 IN factor
|
||||
WHILE n >= factor:
|
||||
SELECT:
|
||||
n mod factor = 0:
|
||||
INSERT factor IN factors
|
||||
PUT n/factor IN n
|
||||
ELSE:
|
||||
PUT factor+1 IN factor
|
||||
RETURN factors
|
||||
|
||||
HOW TO RETURN digit.sum n:
|
||||
PUT 0 IN sum
|
||||
WHILE n > 0:
|
||||
PUT sum + (n mod 10) IN sum
|
||||
PUT floor (n/10) IN n
|
||||
RETURN sum
|
||||
|
||||
HOW TO REPORT smith.number n:
|
||||
PUT factors n IN facs
|
||||
IF #facs = 1: FAIL
|
||||
PUT 0 IN fac.dsum
|
||||
FOR fac IN facs:
|
||||
PUT fac.dsum + digit.sum fac IN fac.dsum
|
||||
REPORT fac.dsum = digit.sum n
|
||||
|
||||
PUT 0 IN col
|
||||
FOR i IN {1..9999}:
|
||||
IF smith.number i:
|
||||
WRITE (i>>5)
|
||||
PUT col+1 IN col
|
||||
IF col=16:
|
||||
WRITE /
|
||||
PUT 0 IN col
|
||||
WRITE /
|
||||
Loading…
Add table
Add a link
Reference in a new issue