Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,20 @@
HappyNumbers arg;⎕IO;∆roof;∆first;bin;iroof
[1] ⍝0: Happy number
[2] ⍝1: http://rosettacode.org/wiki/Happy_numbers
[3] ⎕IO1 ⍝ Index origin
[4] ∆roof ∆first2arg,10
[5]
[6] bin{
[7] ⍝ Default left arg
[8] =1:1 ⍝ Always happy!
[9]
[10] numbers¨1 ⍝ Split numbers into parts
[11] next+/{*2}¨numbers ⍝ Sum and square of numbers
[12]
[13] next:0 ⍝ Return 0, if already exists
[14] (,next) next ⍝ Check next number (recursive)
[15]
[16] }¨iroof∆roof ⍝ Does all numbers upto ∆root smiles?
[17]
[18] ~0¨∆firstbin/iroof ⍝ Show ∆first numbers, but not 0

View file

@ -0,0 +1,14 @@
HappyNumbers{ ⍝ return the first ⍵ Happy Numbers
⍝ initial list
=+/: ⍝ 1's mark happy numbers
sq× ⍝ square function (times selfie)
isHappy{ ⍝ is ⍵ a happy number?
⍝ previous sums
=1:1 ⍝ if we get to 1, it's happy
n+/sq¨ ⍝ sum of the square of the digits
n:0 ⍝ if we hit this sum before, it's not happy
(,n) n} ⍝ recurse until it's happy or not
(,isHappy 1+) ⍝ recurse until we have ⍵ happy numbers
}
HappyNumbers 8
1 7 10 13 19 23 28 31