mirror of
				https://github.com/coolaj86/fizzbuzz.git
				synced 2024-11-16 17:29:04 +00:00 
			
		
		
		
	Yay for FizzBuzz!
This commit is contained in:
		
						commit
						d51959eda0
					
				
							
								
								
									
										9
									
								
								README
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								README
									
									
									
									
									
										Normal file
									
								
							@ -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
									
								
								fibonacci.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										16
									
								
								fibonacci.js
									
									
									
									
									
										Executable file
									
								
							@ -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
									
								
								fizzbuzz.js
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										21
									
								
								fizzbuzz.js
									
									
									
									
									
										Executable file
									
								
							@ -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
									
								
								fizzbuzz.rb
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										6
									
								
								fizzbuzz.rb
									
									
									
									
									
										Executable file
									
								
							@ -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
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user