Skip to content

Commit

Permalink
Yay for FizzBuzz!
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ ONeal committed Jun 26, 2010
0 parents commit d51959e
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FizzBuzz
========

An array of the usual suspects - Hello World, FizzBuzz, Fibonacci, more to come...

TODO
----
* Echo Client / Server
* Ajax Chat
16 changes: 16 additions & 0 deletions fibonacci.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env node
"use strict";
var sys = require('sys');
(function () {
var seq = [];
function fibonacci(a, b) {
seq.push(a);
if (a >= 100) {
seq.push(b);
return;
}
fibonacci(b, a+b);
}
fibonacci(0,1);
sys.print(seq.join(', ') + "\n");
}());
21 changes: 21 additions & 0 deletions fizzbuzz.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env node
"use strict";
var sys = require('sys');
(function () {
var i, n;
for (i = 1; i <= 100; i += 1) {
n = false;

if (0 === (i % 3)) {
n = true;
sys.print("Fizz");
}
if (0 === (i % 5)) {
n = true;
sys.print("Buzz");
}
if (true === n) {
sys.print("\n");
}
}
}());
6 changes: 6 additions & 0 deletions fizzbuzz.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env ruby
(1..100).each do |x|
print "Fizz" if 0 == (x % 3)
print "Buzz" if 0 == (x % 5)
print "\n" if 0 == (x % 3) || 0 == (x % 5)
end
6 changes: 6 additions & 0 deletions hello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env node
"use strict";
var sys = require('sys');
(function () {
sys.print("Hello World!\n");
}());

0 comments on commit d51959e

Please sign in to comment.