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! (:
Brody Cruz
----------
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! (:
Grayson Cook
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! (:
Isaac Stewart
This might be bad or not what you asked for, but I'm too drunk to code well
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! (:
Julian Bennett
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! (:
Angel Baker
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! (:
Owen Long
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! (:
Carson Reed
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! (:
Mason Flores
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.
Wyatt Morris
Fuck the shitty signatures itt and fuck your fizzbuzz
Kayden Torres
>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! (:
Leo Lewis
for(var i = 1; i
Blake Gutierrez
>autism
Leo Gonzalez
[quote]for(var i = 1; i
Eli Jenkins
# 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()
Caleb Baker
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! (:
David Myers
>97% of the internet is racist, homophobic, transphobic or all three. source?
Oliver Fisher
I'm genuinely curious, do non-silicon valley companies ask these types of stupid questions or is this just a meme?
Joshua Long
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)
Caleb Gutierrez
>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! (:
Chase Hall
(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))
Matthew Butler
#include
int main() { for(int i = 1;i
Benjamin Martin
you faggot nigger mentally ill cock sucker; answer my question
Michael Wilson
i/5/3 == i/3/5 == i/15
Brayden Miller
but why
Isaiah Harris
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.
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.
Connor Foster
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.
Ian Campbell
I don't know why, but it's not registering in my fucking brain. I might be retarded.
Landon Wood
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
Bentley Russell
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