Skip to content

Commit

Permalink
new file: scripts/subscript_numbers.sf
Browse files Browse the repository at this point in the history
  • Loading branch information
trizen committed Aug 9, 2015
1 parent e9f427f commit 1c56099
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ scripts/static_const_lazy_init.sf
scripts/string_encodings.sf
scripts/string_escapes.sf
scripts/struct_definition.sf
scripts/subscript_numbers.sf
scripts/sum_of_squares.sf
scripts/switch.sf
scripts/sylvesters_sequence.sf
Expand Down
21 changes: 21 additions & 0 deletions scripts/subscript_numbers.sf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/ruby

var (x₀=1, x₁=7, y₀=3, y₁=4);

var a₀ = (x₀ * y₀);
var b₀ = (a₀ % 10);
assert_eq(3, b₀);

var a₁ = ((x₁ * y₀) + floor(a₀ / 10));
var a₂ = (x₀ * y₁);
var b₁ = ((a₁ % 10) + (a₂ % 10));
assert_eq(5, (b₁ % 10));

var a₃ = ((x₁ * y₁) + floor(a₂ / 10));
var b₂ = (floor(a₁ / 10) + (a₃ % 10) + floor(b₁ / 10));
assert_eq(0, (b₂ % 10));

var b₃ = (floor(a₃ / 10) + floor(b₂ / 10));
assert_eq(3, b₃);

say "** Test passed!";

0 comments on commit 1c56099

Please sign in to comment.