[ create a new paste ] login | about

Project: programmingpraxis
Link: http://programmingpraxis.codepad.org/RqYg0Qfi    [ raw code | output | fork | 1 comment ]

programmingpraxis - Scheme, pasted on Feb 24:
(define (julian year month day)
  (let* ((a (quotient (- 14 month) 12))
         (y (+ year 4800 (- a)))
         (m (+ month (* 12 a) -3)))
    (+ day
       (quotient (+ (* 153 m) 2) 5)
       (* 365 y)
       (quotient y 4)
       (- (quotient y 100))
       (quotient y 400)
       (- 32045))))

(define (fri13-ten year month)
  (let loop ((m (if (= month 12) 1 (+ month 1)))
             (y (if (= month 12) (+ year 1) year))
             (n 0) (k 120))
    (if (zero? k) n
      (loop (if (= m 12) 1 (+ m 1))
            (if (= m 12) (+ y 1) y)
            (if (= (modulo (julian y m 13) 7) 4) (+ n 1) n)
            (- k 1)))))

(display (fri13-ten 2009 3))


Output:
1
17


Create a new paste based on this one


Comments:
posted by DEBRA33Dejesus on Dec 22
Some time ago, I did need to buy a building for my firm but I didn't have enough money and could not purchase something. Thank heaven my mate proposed to try to take the <a href="http://goodfinance-blog.com/topics/credit-loans">credit loans</a> from trustworthy bank. Thus, I acted so and used to be satisfied with my financial loan.
reply