New twist on an old challenge: print all numbers from 1 to 100...

New twist on an old challenge: print all numbers from 1 to 100, but for every multiple of 3 print the sum of all printed numbers so far instead and for every multiple of 5 print the average of all printed numbers so far. For every multiple of both, print "fizzbuzz."

----------

97% of the internet is racist, homophobic, transphobic or all three. Copy this into your signature if you're one of the 3% who aren't! (:

----------

97% of the internet is racist, homophobic, transphobic or all three. Copy this into your signature if you're one of the 3% who aren't! (:

total = 0
avg = 0
for ii in range(1, 101):
if (ii % 15 == 0):
print "fizzbuzz"
continue
if (ii % 3 == 0):
print total
total += total
elif (ii % 5 == 0):
avg = float(total) / (ii - 1)
print avg
total += avg
else:
print ii
total += ii
Easy.

----------

97% of the internet is racist, homophobic, transphobic or all three. Copy this into your signature if you're one of the 3% who aren't! (:

This might be bad or not what you asked for, but I'm too drunk to code well

#include
int main(){
int i, total;
for(i = 0; i

>all printed numbers
You're adding numbers you're skipping.

----------

97% of the internet is racist, homophobic, transphobic or all three. Copy this into your signature if you're one of the 3% who aren't! (:

Does that mean all the averages and sums printed so far as well? This is a confusing challenge, OP.

----------

97% of the internet is racist, homophobic, transphobic or all three. Copy this into your signature if you're one of the 3% who aren't! (:

cool thread OP

----------

97% of the internet is racist, homophobic, transphobic or all three. Copy this into your signature if you're one of the 3% who aren't! (:

It's every number printed so far; it's not confusing at all.

----------

97% of the internet is racist, homophobic, transphobic or all three. Copy this into your signature if you're one of the 3% who aren't! (:

samefag

----------

97% of the internet is racist, homophobic, transphobic or all three. Copy this into your signature if you're proud to be a member of the rational majority! (:

Your shitty instructions are ambiguous and don't make it clear whether the "fizzbuzz" is being printed in addition to or in place of the operations for the multiples.

Anybody who has posted an "answer" is retarded.

Fuck the shitty signatures itt and fuck your fizzbuzz

>can't fill in the blanks with context
>not retarded

----------

97% of the internet is racist, homophobic, transphobic or all three. Copy this into your signature if you're one of the 3% who aren't! (:

for(var i = 1; i

>autism

[quote]for(var i = 1; i

# New twist on an old challenge: print all numbers from 1 to 100,
# but for every multiple of 3 print the sum of all printed numbers
# so far instead and for every multiple of 5 print the average of
# all printed numbers so far. For every multiple of both, print "fizzbuzz."
from __future__ import print_function

def check_number(num, total):
if num % 3 == 0 and num % 5 == 0:
print("FizzBuzz")
elif num % 3 == 0:
print(sum(total))
elif num % 5 == 0:
print(float(sum(total))/len(total))
else:
print(num)
return total.append(num)

def main():
total = []
for i in range(1, 100):
check_number(i, total)

if __name__ == "__main__":
main()

var arr=[],
a=101
while(a)
(--a!isNaN(a)).reduce((a,b)=>a+b)/[...arr].filter(a=>!isNaN(a)).length
:
[...arr].filter(a=>!isNaN(a)).reduce((a,b)=>a+b)
)


----------

97% of the internet is racist, homophobic, transphobic or all three. Copy this into your signature if you're one of the 3% who aren't! (:

>97% of the internet is racist, homophobic, transphobic or all three.
source?

I'm genuinely curious, do non-silicon valley companies ask these types of stupid questions or is this just a meme?

Serious question, why isn't it (number % 5 == 0 && number % 3 == 0), you're asking if they're multiples of both so why the fuck are people doing (number % 15 == 0)

>wasting cpu cycles for 2 statements
holy shit.......

----------

97% of the internet is racist, homophobic, transphobic or all three. Copy this into your signature if you're one of the 3% who aren't! (:

(import (srfi srfi-1))

(define (fb n total)
(let* ((div5? (= 0 (remainder n 5)))
(div3? (= 0 (remainder n 3)))
(pnum (cond
((and div3? div5?) 0)
(div3? total)
(div5? (/ total (1- n)))
(else n))))
(format #t "~A\n" (if (= 0 pnum) "fizzbuzz" pnum))
(+ total pnum)))

(fold fb 0 (iota 100 1))

#include

int main() {
for(int i = 1;i

you faggot nigger mentally ill cock sucker; answer my question

i/5/3 == i/3/5 == i/15

but why

Oh ok.
It's because it's the simplest and fastest option.
It's like saying why write 15 when you can just write 3 * 5.

i/5 = i/1 * 1/5
i/3 = i/1 * 1/3
i/3/5 = i/1 * 1/3 * 1/5
i/5/3 = i/1 * 1/5 * 1/3

1/3*1/5 is 1/15

3 * 5 is 15 but it's asking you to determine whether the number is multiples of both 3 and 5 not the product of 3 and 5, so whats up? Talk to me.

Say n is a number that's evenly divisible by 3 and 5.

Thus it can be said that n can be written as 3*5*m where m is some integer.

n = 3*5*m = 15*m, since m is an integer dividing n by 15 will obviously produce an integer, e.g. no remainder.

I don't know why, but it's not registering in my fucking brain. I might be retarded.

n/3/5 = m

3*5 * n/3/5 = 15 * n/3/5 = n = 15*m

n / 15 = m

Thus if n is divisible by 3 and 5 it's also divisible by 15

you are a fucking retarded brainlet who can't do simple algebra a downs 8 year could do
What the fuck are you doing anywhere near technology; there is no way you could graduate a tech degree or even get into a university with this level of basic fucking ineptitude
If you have anything to with technology it's because you took a web copy/paste bootcamp in HTML/reactJS/php/stackoverflow/sucking cock
Hang yourself and live stream it