// assuming that the input is provided from the command line with 3 different integers
//first A being fizz
//second B being buzz
//third N being the number of integers to be processed
import java.io.*;
import java.util.*;
public class fizzbuzz {
static Scanner console = new Scanner(System.in);
public static void main(String[] args) throws IOException
{
while(console.hasNext())
{
int first=console.nextInt();
int second =console.nextInt();
int third =console.nextInt();
for(int i=1;i<=third;i++)
{
if(i%first==0 && i%second==0 )
{
System.out.printf("FB");
}
else if(i%first==0)
System.out.printf("F");
else if(i%second==0)
System.out.printf("B" );
else
System.out.printf("%d",i);
}
}
}
}
//first A being fizz
//second B being buzz
//third N being the number of integers to be processed
import java.io.*;
import java.util.*;
public class fizzbuzz {
static Scanner console = new Scanner(System.in);
public static void main(String[] args) throws IOException
{
while(console.hasNext())
{
int first=console.nextInt();
int second =console.nextInt();
int third =console.nextInt();
for(int i=1;i<=third;i++)
{
if(i%first==0 && i%second==0 )
{
System.out.printf("FB");
}
else if(i%first==0)
System.out.printf("F");
else if(i%second==0)
System.out.printf("B" );
else
System.out.printf("%d",i);
}
}
}
}
No comments:
Post a Comment