William James
5/16/2016 10:28:00 PM
WJ wrote:
> Wolfram Fenske wrote:
>
> > (defun pythagorean-triplet ()
> > (let ((c2-b2 0) (a 0) (i 0))
> > (loop for c from 2 to 5000 do
> > (loop for b from 1 below c do
> > (progn
> > (setf c2-b2 (- (* c c) (* b b))
> > ;;a (isqrt c2-b2)
> > a (truncate (sqrt c2-b2)))
> > (when (= c2-b2 (* a a))
> > (incf i)))))
> > (print i)))
>
> MatzLisp (Ruby):
>
> def pyth_triplets
> (2..5000).reduce(0){|sum,c|
> sum +
> (1...c).count{|b|
> c2_b2 = c*c - b*b
> a = Math.sqrt(c2_b2).to_i
> c2_b2 == a*a}}
> end
>
> pyth_triplets
> ===>11362
OCaml:
let pyth_triplets () =
let count = ref 0 in
for c = 2 to 5000 do
for b = 1 to c - 1 do
let a = int_of_float (sqrt (float (c*c - b*b))) in
if a*a + b*b = c*c then incr count
done
done ;
!count ;;
--
[T]he organized Jewish community throughout the West has been a major force in
placing penalties on speech related to race, ethnicity, and immigration.
www.theoccidentalobserver.net/2016/03/could-it-happen-here/