0
Mentor
Forth (developed and tested with Win32Forth)
Code:
```variable test3
variable test5
variable prt

: prog 1 0 0 test3 ! test5 ! prt !
20 1 do
test3 @ 1 + dup test3 ! 3 = if ." fizz" 0 0 prt ! test3 ! then
test5 @ 1 + dup test5 ! 5 = if ." buzz" 0 0 prt ! test5 ! then
prt @ if i . else ."  " then
1 prt !
loop ;```
0
Mentor
And a better one that doesn't use variables:
Code:
```: prog1
20 1 do
0
i 3 mod 0= if ." fizz" drop 1 then
i 5 mod 0= if ." buzz" drop 1 then
0= if i . else ."  " then
loop ;```
0
Go4Expert Member
Code:
```<?php
for(\$i = 1; \$i <= 100; \$i++)
{
echo ((\$i%3 ==0) && (\$i%5 ==0)) ? 'FizzBuzz<br>' : ((\$i%3==0) ? 'Fizz<br>' :((\$i%5==0) ? 'Buzz<br>' : "\$i<br>"));
}
?>```
0
~ Б0ЯИ Τ0 С0δЭ ~
@ xpi0t0s : Please do mention the language (atleast in your code-block), before posting any code.

BTW, that code looks like Forth, am I right ??

One more by me : (in HLA = High Level Assembly)
Code: asm
`program FizzBuzz;#include ("stdlib.hhf");static    Number:   int32 := 1;begin FizzBuzz;    mov(101, ebx);    mov(1, Number);    while(Number < ebx) do        mov(0,ecx);        mov(Number,eax);        mov(3,dl);        div(dl);        if (ah = 0) then            mov(1,ecx);            stdout.put("Fizz");        endif;        mov(Number,eax);        mov(5,dl);        div(dl);        if(ah = 0) then            mov(1,ecx);            stdout.put("Buzz");        endif;        if(! ecx) then            stdout.put(Number);        endif;        stdout.put(nl);        inc(Number);    endwhile;end FizzBuzz;  `

Last edited by SaswatPadhi; 28May2009 at 19:21.. Reason: Added HLA Code
0
Mentor
Quote:
Originally Posted by SaswatPadhi
Please do mention the language (atleast in your code-block), before posting any code.

BTW, that code looks like Forth, am I right ??
You are, and I did, but it's on page 1:
Quote:
Originally Posted by xpi0t0s
Forth (developed and tested with Win32Forth)
0
~ Б0ЯИ Τ0 С0δЭ ~
Oh ! : , I didn't see it !
[ Bad habit of jumping to the last post, directly ]
0
~ Б0ЯИ Τ0 С0δЭ ~
Finalllyyyy... After struggling with BrainF*ck for 3 hours, I conclude that the language truly justifies its name !

Here is my BF code for some thing as simple as a Fizz-Buzz test :

Code:
```<    * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
# *   (+) FIZZ-BUZZ PROGRAM BY SASWAT PADHI >             *
# # *                                                       *
# # *   This BrainF*ck program is written by Saswat Padhi   *
# # *   I have done much labour on this code as writing a   *
# # *   BF code is not easy; even harder than ASM     ;)    *
# # *                                                       *
# # *   Believe it or not I have spent 3 hours writing this *
# # *   shit(looking) code !                                *
# # *                                                       *
# # *   If you want to use this code; please give me some   *
# # *   credit by atleast mentioning my name :) Thanks      *
# # *                                                       *
# # *   PLEASE NOTE THAT THIS IS THE UNCOMMENTED VERSION OF *
# # *   MY ORIGINAL FIZZBUZZ PROGRAM; SO BETTER NOT TO TRY  *
# # *   READING IT ;)     IF YOU WANT A MORE HUMAN_FRIENDLY *
# # *   VERSION THAT IS WELL COMMENTED; YOU MAY CONTACT ME  *
# # *                                                       *
# # * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # #     >

************************************************************************
******************** FIZZBUZZ BF SOURCE CODE BEGINS ********************
************************************************************************
**                                                                    **
**                                                                    **
**  >++++++++++++++++++++++++++++++++++++++++++++[[>]+++++++++++++++  **
**  ++++++++++++++++++++++++++++++++++++++++++++++++++[<]>-]>+++++.>  **
**  ++++++++.>+++++++++++++++++++++++++.>+++++++++++++++++++++++++.>  **
**  --------------------.>+.>++++++++++++++++++++.>+++++++++++++++++  **
**  ++++++++.>+++++++++++++++++++++++++.>---------------------------  **
**  ------.>+++++++++++++++.>+++++++++++++++++.>++++++++++++++.>++++  **
**  ++.>+++++++++++++++++.>.>++++++++++++.>-------------------------  **
**  --------.>+.>++++++++++++++++++++++++.>-------------------------  **
**  --------.>++++++++++++++++++.>.>++++++++++++++++++.>++++++++++++  **
**  ++++++++++.>.>+++++++++++++++++++.>-----------------------------  **
**  ----.>+++++++++++++++.>.>+++.>+++++++.>++++++++.>---------------  **
**  ----------------------------------------..>---------------------  **
**  -------------------------------------------->+++++>++++++++>++++  **
**  +++++++++++++++++++++>+++++++++++++++++++++++++>----------------  **
**  ------------------------------------------------->+>++++++++++++  **
**  ++++++++>+++++++++++++++++++++++++>+++++++++++++++++++++++++>>++  **
**  ++++++++>>++++++++++++++++++++++++++++++++++++++++++++++++>+++++  **
**  ++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++>  **
**  >>>>>>>>>++<<<<<<<<<<<<<<[>++++++++++>>----------<<[>>+>>[-]>[-]  **
**  >[-]>[-]+>[-]+>[-]+>[-]>[-]>[-]>+>[-]<[>+>+<<-]>>[<<+>>-]<<---[<  **
**  <<<<<[-]>>>>>[-]+>-]<[>>[<+>-]>+<<<-]>>>[<<<+>>>-]<<<<<<<<<<<<<[  **
**  >>+>+<<<-]>>>------------------------------------------------[>>  **
**  >[-]>>[-]+<<<<+<-]>[<+>-]<-----[>>>>[-]>>[-]+<<<<<<-]<[<<+>>-]>>  **
**  >[<<<<<<<<<<[<]<[<]>.>.>.>.>>>>>>>>>>>>>>>-]>[<<<<<<<<<<<[<]>.>.  **
**  >.>.>>>>>>>>>>>-]>[<<<<<<<<<<<<[<]>.>.>.>.>>>>>>>>>>>>-]>[>[>[<<  **
**  <<<<<<<<<.>.>>>>>>>>>>-]<-]<-]<<<<<<<.<<<-]>+<<-]<<[<]>.>.>.>.<>  **
**                                                                    **
**                                                                    **
************************************************************************
******************** END OF FIZZBUZZ BF SOURCE CODE ********************
************************************************************************

Program Size    :: 4254 bytes
Instructions    :: 1669
Number of moves :: 694083
Average RunTime :: 30 ms

Notes :
(*) Compile with option "Allow wrapping of pointers = TRUE"
(*) Compile with option "Allow wrapping of values = TRUE"```
0
Go4Expert Founder
Thats really a BrainF*ck really
0
Team Leader
:O That's some code. For people who don't know about Brain*uck check this link http://cydathria.com/bf/
0
Team Leader
Code: JavaScript
`for(var i = 1; i <= 100; i++){    document.write(((i%3 ==0) && (i%5 ==0)) ? 'FizzBuzz<br>' : ((i%3==0) ? 'Fizz<br>' :((i%5==0) ? 'Buzz<br>' : i+"<br>")));}`