1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

周期性を利用したFizzBuzz

Posted at

だいぶ前に書いたけど最近Qiitaが熱いらしいので(以下略

fizzbuzz.scm
(define fizzbuzz '(1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 Fizzbuzz))

(define (solve n)
  (let loop ((num 1)(lst fizzbuzz)(m 1))
	(cond 
	  ((null? lst)
	   (loop num (map (lambda(x)(if (number? x)(+ x (* 15 m)) x)) fizzbuzz) (+ m 1)))
	  ((>= n num)
	   (print (car lst))
	   (loop (+ num 1) (cdr lst) m)))))
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?