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
|
|
@ -0,0 +1,27 @@
|
|||
Integer method: properDivs
|
||||
| i l |
|
||||
ListBuffer new dup add(1) ->l
|
||||
2 self nsqrt tuck for: i [ self i mod ifFalse: [ l add(i) l add(self i / ) ] ]
|
||||
sq self == ifTrue: [ l removeLast drop ]
|
||||
l sort ;
|
||||
|
||||
: aliquot(n) // ( n -- aList ) : Returns aliquot sequence of n
|
||||
| end l |
|
||||
2 47 pow ->end
|
||||
ListBuffer new dup add(n) dup ->l
|
||||
while (l size 16 < l last 0 <> and l last end <= and) [ l last properDivs sum l add ] ;
|
||||
|
||||
: aliquotClass(n) // ( n -- aList aString ) : Returns aliquot sequence and classification
|
||||
| l i j |
|
||||
n aliquot dup ->l
|
||||
l last 0 == ifTrue: [ "terminate" return ]
|
||||
l second n == ifTrue: [ "perfect" return ]
|
||||
l third n == ifTrue: [ "amicable" return ]
|
||||
l indexOfFrom(n, 2) ifNotNull: [ "sociable" return ]
|
||||
|
||||
l size loop: i [
|
||||
l indexOfFrom(l at(i), i 1 +) -> j
|
||||
j i 1 + == ifTrue: [ "aspiring" return ]
|
||||
j ifNotNull: [ "cyclic" return ]
|
||||
]
|
||||
"non-terminating" ;
|
||||
Loading…
Add table
Add a link
Reference in a new issue