You are viewing our Forum Archives. To view or take place in current topics click here.
I have a Programming Challenge for you!
Posted:

I have a Programming Challenge for you!Posted:

Antoldi95
  • Junior Member
Status: Offline
Joined: Jun 07, 201311Year Member
Posts: 51
Reputation Power: 2
Status: Offline
Joined: Jun 07, 201311Year Member
Posts: 51
Reputation Power: 2
Here is a challenge for you!

Looking over some forums people have asked for programming challenges!

Well, I can't seem to locate the same chalenge on TTG so I thought I would post it. If its already been done many times just let me know and I will take it down ;). Pretty simple if you know what your doing.

Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".

Didn't take me long. Should be easy if you know what your doing. Lets see how you all do!

Post your answers below. Kyle, I'm sure you know this one. If no-one gets it after 48hrs. I'll post the answer



"Credit for this goes to Jeff atwood"
#2. Posted:
Kyle93
  • Retired Staff
Status: Offline
Joined: Jun 25, 201014Year Member
Posts: 4,078
Reputation Power: 2628
Motto: https://www.thetechgame.com/Forums/t=7804 333/vote-for-tune-of-the-week-friday-nigh ts-lockdown-dj-sets.html
Motto: https://www.thetechgame.com/Forums/t=7804 333/vote-for-tune-of-the-week-friday-nigh ts-lockdown-dj-sets.html
Status: Offline
Joined: Jun 25, 201014Year Member
Posts: 4,078
Reputation Power: 2628
Motto: https://www.thetechgame.com/Forums/t=7804 333/vote-for-tune-of-the-week-friday-nigh ts-lockdown-dj-sets.html
This was posted before, however it's gone walkie. Here is my solution for this in Java.

public class Main {
   public static void main(String[] args) {
      for( int i = 0 ; i <= 100 ; i++ ){
         if( i % 5 == 0 && i % 3 == 0 ) System.out.println( i + " FizzBuzz");
         else if( i % 3 == 0 ) System.out.println( i + " Fizz");
         else if( i % 5 == 0 ) System.out.println( i + " Buzz");
         else System.out.println(i);   
      }
   }
}
#3. Posted:
speed
  • Winter 2023
Status: Offline
Joined: Jun 11, 200915Year Member
Posts: 9,897
Reputation Power: 3160
Motto: "I'l no I grew up to fast speed I no u will be little famous" - Famous_Energy
Motto: "I'l no I grew up to fast speed I no u will be little famous" - Famous_Energy
Status: Offline
Joined: Jun 11, 200915Year Member
Posts: 9,897
Reputation Power: 3160
Motto: "I'l no I grew up to fast speed I no u will be little famous" - Famous_Energy
Here's my code from the last time this was posted.

<?php for($i=1;$i<101;$i++){echo(($i%15==0)?"FizzBuzz<br/>":(($i%5==0)?"Buzz<br/>":(($i%3==0)?"Fizz<br/>":$i."<br/>")));}?>
#4. Posted:
M0D1F13D
  • TTG Senior
Status: Offline
Joined: Sep 06, 201014Year Member
Posts: 1,069
Reputation Power: 47
Status: Offline
Joined: Sep 06, 201014Year Member
Posts: 1,069
Reputation Power: 47
for x in range(1,101):
    if (((x%3) == 0) & ((x%5) == 0)):
        print 'FizzBuzz'
    elif ((x%3) == 0):
        print 'Fizz'
    elif ((x%5) == 0):
        print 'Buzz'
    else: print x
#5. Posted:
Antoldi95
  • Junior Member
Status: Offline
Joined: Jun 07, 201311Year Member
Posts: 51
Reputation Power: 2
Status: Offline
Joined: Jun 07, 201311Year Member
Posts: 51
Reputation Power: 2
Haha, We'll. I guess that was too easy xD
#6. Posted:
M0D1F13D
  • TTG Senior
Status: Offline
Joined: Sep 06, 201014Year Member
Posts: 1,069
Reputation Power: 47
Status: Offline
Joined: Sep 06, 201014Year Member
Posts: 1,069
Reputation Power: 47
Antoldi95 wrote Haha, We'll. I guess that was too easy xD

Then post a more difficult one.
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.