H-How's my fizzbuzz guys? Am I ready to finally get a job?

H-How's my fizzbuzz guys? Am I ready to finally get a job?

public static void main(String[] args) {
for (int i = 1; i

Other urls found in this thread:

phpbb.com/community/help/bbcode#f2r1
twitter.com/AnonBabble

>java

LOL

Well you know the modulus operator exists so I guess?

>String[] args
>String
>Capital s
Why would they do that?

>"Sorry but the question was: write a program to sum all the primes under 2 million"
>"We'll call to let you know our decision, now please leave before we call security"

Because you know it's an object that way?

> 4 divisions per iteration
> Not using bbcode code blocks

Good job kid

>"Sorry but the question was: write a program to sum all the primes under 2 million"
Not a question.

Can't you just have if (!(i%3)) ? A non-zero integer should be true, at least in c.

>MuH CamelCaSE

I haven't used java in ages but I'm fairly sure you can't do integer conditions. Has to be a boolean/boolean operator

java is such a trash language

Strongly-type languages don't allow you to do that.

#include

int main()
{
for (int i = 0; i < 50; i++) {
if (i % 3 == 0)
printf("Fizz");
if (i % 5 == 0)
printf("Buzz");
else if (i % 3)
printf("%d", i);
putchar('\n');
}
}

fixd

C is strongly typed though because all variables must have a type. Java is stronger-typed i guess.

i probably should've put a return 0 after that for loop but w/e

What's an prime number?

Just because you have to declare types doesn't mean it's a strongly-typed language. C allows a lot of implicit casting, and performing actions on variables of inappropriate types is often allowed but causes undefined behavior.

function sumit(prime)
if prime[0] > 2000000 begin return False end
if len(prime)

Don't worry about that, we'll train you.

define strongly-typed

>Average C baby
>"durr haha shoulda wrote it in C"
>proceeds to declare a side-effect only function as an int function

Returns an error if you declare a function as an integer and it doesn't return an int.

nice bait

>if (i % 3 == 0 && i % 5 == 0)
replace with
if (i % 15) {
System.out.println("FizzBuzz");
}


nothing that is divisible by 3 AND 5 is not also divisible by the LCM (15)

How is that bait? Did you not write a side-effect only function as a function with an integer return type? Do you not know what a side-effect is, C baby?

In C, the main function is almost always an int so you can return error codes. I just forgot to put return 0 at the end.

A run-time error? an error while compiling? Both cases are bad definitions that hold up for Java too and you may as well say statically/dynamically typed.

compilation error u faggot

(i % 15 == 0)

During the type checking phase of compilation, which is almost always ran on the abstract syntax tree. Are you retarded or something?

You're just repeating what I said. Are you retarded? Your code is shit and you're a bad programmer. Don't explain to me why you're a shit programmer. Just stop being an elitist until you're elite.

String is an object just like there is Integer and Array

why are you so angry about this lmao

C allows integer conditions because C has no primitive boolean. Low level code treats integers like booleans, ie if 0 the ZF (zero flag) is set, otherwise it's not. C++ allows it as an extension on C. Java doesn't allow it because it was designed with things like readability in mind.

But in C it's definitely not cast to anything because there's no primitive boolean to cast it to.

So which is technically faster, using a conditional for mod 15, 5, and 3 causing three branching conditions, or using only mod 5 and 3 and printing a newline at the end?

Am i redy for a jawb goys???

No because you started at 0.

We'll call you at a later date to tell you our decision.

is that chris pratt in the front?

I prefer mine:

#include
#define LEFT_BRACE {
#define RIGHT_BRACE }
#define LEFT_BRACKET [
#define RIGHT_BRACKET ]
#define LEFT_PARENTHESIS (
#define RIGHT_PARENTHESIS )
#define SEMICOLON ;
#define COMMA ,
#define EQUALS =
#define IS_EQUAL_TO ==
#define IS_NOT_EQUAL_TO !=
#define IS_LESS_THAN <
#define IS_GREATER_THAN >
#define IS_LESS_THAN_OR_EQUAL_TO =
#define MODULUS %
#define INCREMENT ++
#define DECREMENT --
#define AND &&
#define OR ||

int main LEFT_PARENTHESIS RIGHT_PARENTHESIS
LEFT_BRACE
int i SEMICOLON
for LEFT_PARENTHESIS i EQUALS 0 SEMICOLON i IS_LESS_THAN_OR_EQUAL_TO 100 SEMICOLON i INCREMENT RIGHT_PARENTHESIS
LEFT_BRACE
if LEFT_PARENTHESIS i MODULUS 3 IS_NOT_EQUAL_TO 0 AND i MODULUS 5 IS_NOT_EQUAL_TO 0 RIGHT_PARENTHESIS
printf LEFT_PARENTHESIS "%d" COMMA i RIGHT_PARENTHESIS SEMICOLON
if LEFT_PARENTHESIS i MODULUS 3 IS_EQUAL_TO 0 RIGHT_PARENTHESIS
printf LEFT_PARENTHESIS "Fizz" RIGHT_PARENTHESIS SEMICOLON
if LEFT_PARENTHESIS i MODULUS 5 IS_EQUAL_TO 0 RIGHT_PARENTHESIS
printf LEFT_PARENTHESIS "Buzz" RIGHT_PARENTHESIS SEMICOLON

printf LEFT_PARENTHESIS " " RIGHT_PARENTHESIS SEMICOLON
RIGHT_BRACE

printf LEFT_PARENTHESIS "\n" RIGHT_PARENTHESIS SEMICOLON
return 0 SEMICOLON
RIGHT_BRACE

By standard, the main function MUST return int. While some compilers may allow you to get away with only a warning for making main a void function, the fact remains that any other return type for main is invalid C.

Don't chastise programmers for following standard. You are the one who is in the wrong for thinking he should declare it in any other way.

The program is I/O bound. The cost of an extra conditional is negligible.

Really re the original definition:

What if the function returns something that can be casted to an integer? For instance in C++ an object for which `operator int()` is defined. Or in C implicitly casting a string (a `const char*`) to an integral because you _can_ do that but idk why you'd want to.

Strong typing, to me, seems like a spectrum. You have cases like C++ (minus pointer garbage) where user defined implicit type conversions can happen. Or C, which might as well not have types, or OCaml, where God forbid you want to add an int and a float you need to use `float_of_int` and manually convert the type.

Get the fuck out of this interview you fucking retard

This. If you see void main a lot it's because Microsoft's extended version of C++ (Visual C++) allows you to do it and don't even bother to tell you it's wrong.

(mod 3 and mod 5) is faster than mod 15. Most cases fall through to the else block, and in that case there's 2 divisions.

if you want to test it for yourself, replace the print calls with variable counters, change the limit from 50 to 5 million. and time it.

> program is I/O bound
(technically)

>(technically)
You seem dismissive. Do you see I/O bound vs CPU bound as irrelevant for tuning the performance of a program?

>replace with
>if (i % 15) {
Skip this entirely and append to string and print i if string is empty.

> The cost of an extra conditional is negligible.
> You seem dismissive

he asked

> So which is technically faster, using a conditional for mod 15, 5, and 3 causing three branching conditions, or using only mod 5 and 3

Technically 2 divisions will always be faster than 3. Does replacing
if (i % 3 == 0 && i % 5 == 0)
with
if (i % 15 == 0)

change the amount of I/O?

It doesn't change the amount of I/O at all. What I'm saying is that the cost difference between the two is minute compared to the cost of the I/O that is going to happen. While you should obviously be doing mod 15 instead of making two checks (if nothing else, it's less typing), there is no noticeable performance gain.

ok stay with me here.

> doesn't change the amount of I/O at all

exactly. so take the I/O out.

int i, a, b, c, d;
a = b = c = d = 0;

for (i = 1; i

how do i write inline code segments like u cool fellas

the real bottleneck (besides I/O) is branch misprediction. Saying I/O is a bottleneck is kind of pointless becuase if one were concerned about performance you would create a string and print it once at the end of the program.

phpbb.com/community/help/bbcode#f2r1

>phpbb.com/community/help/bbcode#f2r1
til Sup Forums is php garbage

That was not my question.
I was asking if it is better to do
if (i % 3 == 0) print("Fizz")
if (i % 5 == 0) print("Buzz")
print("\n")
thus forcing two branches every time vs the worst case of the previous if-else blocks.

That would be slower. More branch misprediction.

['Fizz'*(not i%3) + 'Buzz'*(not i%5) or i for i in range(1, 101)]

>copy'd from stackoverflow

>work at a publishing house, media production, not even it
>boss comes in "hey user, i don't have much time today, can you please do the job interview scheduled for 2pm?"
>"sure boss"
>get there, some cute girl is there
>do the job interview routine, all went well
>"just one more thing .... can you fizzbuzz?"
what have you done to me, Sup Forums?

NERD.

Please stop trying to force this.

~~~
50.times do |i|
out = ""
out += "Fizz" unless i%3
out += "Buzz" unless i%5
out += i.to_s if out==""
p out
end

Real talk, if I can do all these pointless coding exercises on Leetcode and whatnot and explain why I'm doing what I'm doing, I should be fine at an entry level position right? I mean I have a degree too but these bullshit "let's just see if you can program at all" problems are really all they give you right?

Honestly coding exercises are bullshit and are pointless on resume. They look better than nothing, but a company wants to see you're capable of managing a larger project, contributing to open source, extensions to existing software etc.

If its dividabli with 3 print fiss
if not print buzz
else print fizzbuss

Fucking hell user

max kek