Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
3
Task/Happy-numbers/Mathematica/happy-numbers-1.math
Normal file
3
Task/Happy-numbers/Mathematica/happy-numbers-1.math
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
AddSumSquare[input_]:=Append[input,Total[IntegerDigits[Last[input]]^2]]
|
||||
NestUntilRepeat[a_,f_]:=NestWhile[f,{a},!MemberQ[Most[Last[{##}]],Last[Last[{##}]]]&,All]
|
||||
HappyQ[a_]:=Last[NestUntilRepeat[a,AddSumSquare]]==1
|
||||
2
Task/Happy-numbers/Mathematica/happy-numbers-2.math
Normal file
2
Task/Happy-numbers/Mathematica/happy-numbers-2.math
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
HappyQ[1337]
|
||||
HappyQ[137]
|
||||
2
Task/Happy-numbers/Mathematica/happy-numbers-3.math
Normal file
2
Task/Happy-numbers/Mathematica/happy-numbers-3.math
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
True
|
||||
False
|
||||
12
Task/Happy-numbers/Mathematica/happy-numbers-4.math
Normal file
12
Task/Happy-numbers/Mathematica/happy-numbers-4.math
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
m = 8;
|
||||
n = 1;
|
||||
i = 0;
|
||||
happynumbers = {};
|
||||
While[n <= m,
|
||||
i++;
|
||||
If[HappyQ[i],
|
||||
n++;
|
||||
AppendTo[happynumbers, i]
|
||||
]
|
||||
]
|
||||
happynumbers
|
||||
1
Task/Happy-numbers/Mathematica/happy-numbers-5.math
Normal file
1
Task/Happy-numbers/Mathematica/happy-numbers-5.math
Normal file
|
|
@ -0,0 +1 @@
|
|||
{1, 7, 10, 13, 19, 23, 28, 31}
|
||||
Loading…
Add table
Add a link
Reference in a new issue