Results 1 to 5 of 5

Thread: FizzBuzz

  1. #1
    Join Date
    Sep 2015
    Location
    USA
    Posts
    8
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Smile FizzBuzz

    So, this is actually a double whammy...and I'm pretty excited.

    I never attempted FizzBuzz before, and this is basically the first code I did on my own in Pascal / Simba.

    https://github.com/AshtonHarding/FizzBuzz/

    I feel like I did pretty good. The only google search I did was to find out how to state modulus
    in pascal, since % wasn't working.

    What do you guys think? Is my formatting alright? Is my logic alright, or is there a better/faster way to do it?
    ~~
    [signature]

  2. #2
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    I'm not sure if this is intended, if you count is mod 3 = 0 and mod 5 = 0 it will print
    [code]fizzbuzz
    fizz
    [\code]
    [simba]if(count mod 3 = 0) and (count mod 5 = 0) then
    writeLn('fizzbuzz');

    if(count mod 3 = 0) then
    writeLn('fizz');[\simba]

    Edit: looks like my phone messed up the tags

  3. #3
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    The logic is repetitive, but for a first attempt it is good. I learned how to do these programming exercises at www.codingbat.com
    It has tons of different questions and tests edge cases for you. I highly recommend checking it out if you want to strengthen your logic brain.

  4. #4
    Join Date
    Feb 2007
    Location
    PA, USA
    Posts
    5,240
    Mentioned
    36 Post(s)
    Quoted
    496 Post(s)

    Default

    Quote Originally Posted by dream_loli View Post
    So, this is actually a double whammy...and I'm pretty excited.

    I never attempted FizzBuzz before, and this is basically the first code I did on my own in Pascal / Simba.

    https://github.com/AshtonHarding/FizzBuzz/

    I feel like I did pretty good. The only google search I did was to find out how to state modulus
    in pascal, since % wasn't working.

    What do you guys think? Is my formatting alright? Is my logic alright, or is there a better/faster way to do it?
    try case statement or at least if/else to reduce repetition.

    This is fun, I remember the first time my dad asked me to solve fizbuzz when I was a wee lad! (11 or 12, god, back when I was smart)

  5. #5
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    Quote Originally Posted by BMWxi View Post
    I'm not sure if this is intended, if you count is mod 3 = 0 and mod 5 = 0 it will print
    [code]fizzbuzz
    fizz
    [\code]

    [simba]if(count mod 3 = 0) and (count mod 5 = 0) then
    writeLn('fizzbuzz');

    if(count mod 3 = 0) then
    writeLn('fizz');[\simba]

    Edit: looks like my phone messed up the tags
    Code:
    fizzbuzz
    fizz
    Simba Code:
    if(count mod 3 = 0) and (count mod 5 = 0) then
      writeLn('fizzbuzz');
    if(count mod 3 = 0) then
      writeLn('fizz');

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •