about summary refs log tree commit diff
path: root/usth/ICT3.2/prac/2/6.js
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2020-12-03 09:32:13 +0700
committerNguyễn Gia Phong <mcsinyx@disroot.org>2020-12-03 09:32:13 +0700
commit8644699f4d2fce12a41289f9627bc45be9dd1965 (patch)
treed31190ac36d10e297eeab0f6e7a70dc24395695d /usth/ICT3.2/prac/2/6.js
parent82048ad9e3e4a96a38c8fa6a529798f40e33acb1 (diff)
downloadcp-8644699f4d2fce12a41289f9627bc45be9dd1965.tar.gz
[usth/ICT3.2] Develop web applications
Diffstat (limited to 'usth/ICT3.2/prac/2/6.js')
-rw-r--r--usth/ICT3.2/prac/2/6.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/usth/ICT3.2/prac/2/6.js b/usth/ICT3.2/prac/2/6.js
new file mode 100644
index 0000000..52cb82a
--- /dev/null
+++ b/usth/ICT3.2/prac/2/6.js
@@ -0,0 +1,11 @@
+const A039943 = [0, 1, 4, 16, 20, 37, 42, 58, 89, 145];  // OEIS
+
+for (i = j = 1; i < 11; ++j) {
+    for (k = j;
+         !A039943.includes(k);
+         k = k.toString().split('').map(n => n*n).reduce((m, n) => m+n));
+    if (k == 1) {
+        console.log(j);
+        i++;
+    }
+}