DEBIAN PRO

DEBIAN PRO
DEBIAN

martes, 27 de octubre de 2015

Picat languaje


Estoy probando un "nuevo" lenguaje de Programación.

picat.
cl(p1)
main.
Sum of all the multiples of 3 or 5 below 1000 is 233168

Ejemplos aqui
http://www.hakank.org/picat/



FICHERO p1.pi
/*********************************************************
http://projecteuler.net/problem=1

If we list all the natural numbers below 10 that are
multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these
multiples is 23.

Find the sum of all the multiples of 3 or 5 below 1000.
*********************************************************/

main =>
S = sum([I : I in 1..999, (I mod 3 = 0; I mod 5 = 0)]),
writef("Sum of all the multiples of 3 or 5 below 1000 is %w%n",S).


/* here is another implementation
main =>
S = 0,
foreach (I in 1..999)
if (I mod 3 = 0; I mod 5 = 0) then
S:=S+I
end
end,
writef("Sum of all the multiples of 3 or 5 below 1000 is %w%n",S).
*/

No hay comentarios:

Publicar un comentario