Euler problem 12.1.1

(defmacro sq (x)
  `(* ,x ,x))

(defmacro last-item (lst)
  `(car (last ,lst)))

(defun good-reverse (lst)
  (labels ((rev (lst acc)
             (if (null lst)
                 acc
                 (rev
                  (cdr lst)
                  (cons (car lst) acc)))))
    (rev lst nil)))

(defun prime-sieve-a-list (input-lst)
  (labels ((sieve-iter (go-lst acc-list)
             (if (not go-lst) 
                 acc-list        
                 (if (> (sq (car go-lst))
                        (last-item go-lst))

                     (append (good-reverse acc-list)
                             go-lst)
                     
                     (sieve-iter
                      (remove-if #'(lambda (x)
                                     (=
                                      (mod x
                                           (car go-lst))
                                      0))
                                 (cdr go-lst))
                      (cons (car go-lst)
                            acc-list))))))

    (sieve-iter input-lst '())))

(defun range (max &key (min 0) (step 1))
  (loop :for n :from min :below max :by step
        collect n))

(defmacro prime-sieve (n)
  `(prime-sieve-a-list (cons 2
                             (range (1+ ,n)
                                    :min 3
                                    :step 2))))


(time (length (prime-sieve 20000000)))

;; Evaluation took:
;; 19.907 seconds of real time

What is the value of the first triangle number to have over five hundred divisors?

(defun factor-iter (n p-list acc-list)
  (if (NULL p-list)
      acc-list         
      (let* ((p (car p-list))                                   
             (ps (cdr p-list)))  
        (cond ((> (* p p) n)           
               (good-reverse (cons n
                                   acc-list)))
              ((eql (mod n p) 0)
               (factor-iter (floor n p)
                            p-list
                            (cons p acc-list)))   
              ('t
               (factor-iter n ps acc-list))))))

(defparameter *pm* 2000000)

(defparameter *psi* (prime-sieve *pm*))

(defun factor (n)
  (if (> n (expt *pm* 2))
      
      (let ((m (floor (sqrt n))))
        (factor-iter n (prime-sieve m) '()))
      
      (factor-iter n *psi* '())))

(defun group-factors (lst)
  (labels ((gf (acc lst)
             (if (NULL lst)
                 (good-reverse acc)
                 (let* ((p (car lst))
                        (ps (cdr lst))
                        (lp1 (list p 1)))
                   (if (NULL acc)                      
                       (gf (list lp1) ps)                      
                       (if (eql p (caar acc))
                           (gf (cons
                                (list p
                                      (+ 1
                                         (cadar acc)))
                                (cdr acc))
                               ps)                  
                           (gf (cons lp1 acc) ps)))))))    
    (gf '() lst)))

(defmacro sum (lst)
  `(reduce #'+ ,lst))

(defmacro product (lst)
  `(reduce #'* ,lst))

(defun nDiv (n)
  (product (mapcar #'(lambda (x) (1+ (cadr x)))
                   (group-factors (factor n)))))

(defun fm (m n)
  (labels ((tri-div (n)
             (if (evenp n)
                 (* (nDiv (/ n 2)) (nDiv (1+ n)))
                 (* (nDiv n) (nDiv (/ (1+ n) 2))))))    

    (if (> (tri-div n) m)
        (/  (* n (1+ n)) 2) 
        (fm m (+ 1 n)))))

;

(time (fm 500 1))

;; Evaluation took:
;; 0.007 seconds of real time

;; 76576500

— Me@2023-03-25 07:51:18 PM

.

.

2023.03.27 Monday (c) All rights reserved by ACHK

Corsair Vengeance RGB Pro

你有「婚前性」的話,一定不會從一而終。

如果你宣稱,你的「婚前性」對象,由始至現在至未來,只有一位,亦只會有一位的話,那樣,你在一開始時,為何不先與其結婚?

.

第二,數字不是零或一的話,就不知是多少。

.

第三,可以前的話,就可以外。

— Me@2023-03-12 10:28:29 AM

.

.

2023.03.13 Monday (c) All rights reserved by ACHK

G40-70

If you are using SSD, you should turn off the swap file:

1. In command line, run

swapoff --all

2. Backup the file

/etc/fstab

3. Then, in that file, comment out any lines that contain the word “swap”.

— Me@2023-02-14 05:00:26 PM

.

.

2023.02.15 Wednesday (c) All rights reserved by ACHK

Computing Note, 4

08[.]07[.]2002 

1. Use Computer Software to improve/[]upgrade 
your Brain Software  

10[.]07[.]2002 

2. Software Philosophy: 

Use it, enjoy it, but keep your ability 
to live without it. 

<<Conversation with God>>

Enjoy everything, but need nothing! 

(Even people? 
Especially people!) 

.

.

2023.02.11 Saturday (c) All rights reserved by ACHK

FF7R

Crucial MX500 1TB 3D NAND SATA SSD

.

Final Fantasy 7 Remake Steam version testing result:

1. With GTX 1050 Ti as the GPU, the bottleneck is the GPU, not the CPU, even though my CPU itself was weak.

2. However, once the GPU got upgraded, the CPU became the bottleneck.

The following settings can make the game smoother:

3. Set the Texture to Low. However, I do not recommend that.

4. Set the Shadow to Low.

5. Set the number of background people to be zero.

6. Set the resolution to 720p.

.

The following are the less obvious steps to release some CPU pressure:

7. Turn Steam into offline mode.

8. Turn off as many as other programs as possible.

9. In the controller setting, change the controller from the default “XInput” to “XBox 360“. However, I do not recommend that because that would disable the game’s rumble function.

.

After these settings, the game should be able to load Cloud’s headache memory cinematic scenes.

— Me@2023-01-11 12:39:59 AM

.

10. If not, start to repeat pressing the pause button every one second when a scene starts to load.

— Me@2023.01.23 05:17:38 PM

.

.

2023.01.24 Tuesday (c) All rights reserved by ACHK

MSI RTX 3060 Ti VENTUS 2X 8G OCV1 LHR

Visualizing higher dimensions, 2.2 | Remove time from physics, 2

.

Mathematics is local (left brain).

Physics is global (right brain).

— Me@2017-06-22 06:16:59 PM

.

Mathematical processes, i.e. the calculations, are local.

Physical intuitions before a calculation and the interpretations after are global.

— Me@2023-01-13 07:45:24 PM

.

However, in an opposite sense, physics is local and mathematics is global.

— Me@2023-01-14 08:13:17 PM

.

Geometry is global.

Space is what we can see at once.

Dynamics is local.

Time is what we cannot see at once.

— Me@2017-02-07 10:11:34 PM

.

… math is what you get when you remove time from physics.

.

.

2023.01.14 Saturday (c) All rights reserved by ACHK

MSI RTX 3060 VENTUS 2X 12G OC

Meta numbers 2.1 | Zeno’s paradox 5

.

Infinity is not a number. Instead, it is a meta number.

Numbers are for counting things. Infinity cannot be used for counting things. Infinity is for counting natural numbers. It is a number of numbers.

Numbers represent what there are. But infinity cannot do so. Infinity is only meaningful as a potential one.

Infinity and infinitesimal are processes, not states. Numbers are points on the number line. Infinity is not a point, but an arrow pointing to the right.

An infinite set is a set with an infinite number of elements. An infinite set is defined as a set that contains a subset which is as large as the set itself. In other words, the elements of the subset can have one-one correspondence to those of the origin set. The whole can have one-one mapping to the part because it is not a state of finished mappings, but a process.

Processes are meta states. Processes describe how an object changes its states. Processes describe not the states, but the changes.

— Me@2016-06-13 11:43:36 AM

— Me@2023-01-04 10:36:53 PM

.

.

2023.01.05 Thursday (c) All rights reserved by ACHK

PayPal

.

No, because I think we didn’t know what we were doing. I think the hallmark of a really good entrepreneur is that you’re not really going to build one specific company. The goal — at least the way I think about entrepreneurship — is you realize one day that you can’t really work for anyone else. You have to start your own thing.

— Max Levchin

— Founders at Work

.

.

.

2011.03.31 Thursday ACHK

History 4

.

History seems to me so important that it’s misleading to treat it as a mere field of study. Another way to describe it is all the data we have so far.

.

Among other things, studying history gives one confidence that there are good ideas waiting to be discovered right under our noses.

— Paul Graham

.

.

.

2011.03.15 Tuesday ACHK

ANSI Common LISP

.

ANSI Common LISP (by Paul Graham) was the book I borrowed for a Machine Intelligence course project in 2000. My memory was that the author was called “Paul something”. I thought that Paul was the one who had invented LISP.

No. It should be John McCarthy.

Later on, during my teaching-in-high-school period, by a Wikipedia biography, I realized that that Paul was not as great as I thought, because he was not the one who had invented LISP.

However, now, I regard him as one of my five most important teachers.

— Me@2010.03.08

— Me@2011.03.14

.

.

.

2011.03.14 Monday (c) All rights reserved by ACHK

Startup, go ahead!

Startup 6

.

In an essay I wrote a couple years ago I advised graduating seniors to work for a couple years for another company before starting their own. I’d modify that now. Work for another company if you want to, but only for a small one, and if you want to start your own startup, go ahead.

— Paul Graham

.

.

.

2011.03.04 Friday ACHK

Startup 5

.

There are two types of startup ideas: those that grow organically out of your own life, and those that you decide, from afar, are going to be necessary to some class of users other than you.

There are ideas that obvious lying around now. The reason you’re overlooking them is the same reason you’d have overlooked the idea of building Facebook in 2004: organic startup ideas usually don’t seem like startup ideas at first.

— Paul Graham

.

.

.

2011.02.25 Friday ACHK

Extremists

.

And founders and early employees of startups, meanwhile, are like the Birkenstock-wearing weirdos of Berkeley: though a tiny minority of the population, they’re the ones living as humans are meant to. In an artificial world, only extremists live naturally.

— Paul Graham

.

.

.

2011.02.20 Sunday ACHK