Permalink
Browse files

Add Euler Project #1 implementation in PIR

  • Loading branch information...
1 parent 2edaf92 commit e642406ce7a227106beb98dc0f321be49cc4cde5 @leto committed Aug 1, 2009
Showing with 27 additions and 0 deletions.
  1. +27 −0 parrot/001/01.pir
View
@@ -0,0 +1,27 @@
+# Euler Problem #1 in PIR
+# Jonathan "Duke" Leto <jonathan@leto.net>
+# This appears to be the same speed as the Perl 5 implementation
+# with Parrot 1.4.0
+
+.sub 'main' :main
+ .local int sum, max, m, i
+ i = 1
+ max = 999
+ sum = 0
+loop:
+ mod m, i, 3
+ if m == 0 goto found
+ mod m, i, 5
+ if m == 0 goto found
+ inc i
+ if i > max goto done
+ goto loop
+found:
+ sum = sum + i
+ inc i
+ if i > max goto done
+ goto loop
+done:
+ print sum
+ print "\n"
+.end

0 comments on commit e642406

Please sign in to comment.