*Make sure to check out the providers of the best Christmas present this year! :D **brilliant.org/FlammableMaths* Also, Christmas Merch :00000000 teespring.com/new-merry-christmath-golden-ra
@misterg3tr3kt113 жыл бұрын
how is this comment 4 hours old? 4 hours < 4 seconds?🤔🤔🤔
@angelmendez-rivera3513 жыл бұрын
@@misterg3tr3kt11 The video could've been unlisted.
@misterg3tr3kt113 жыл бұрын
@@angelmendez-rivera351 yeah
@latefoolstalk6763 жыл бұрын
Loving those nines that look like "g" because everyone knows π2 = 9 = g
@oferzilberman50493 жыл бұрын
If we say π=3 Then π²=9=g
@michaelempeigne35193 жыл бұрын
pi squared does not = g
@michaelempeigne35193 жыл бұрын
( 16*arctan( 1 / 5 ) - 4*arctan(1 / 239 ) )^2 is not equal to g
@minh95453 жыл бұрын
@@michaelempeigne3519 is this a joke? If it is not, you are clearly missing the point here.
@abcxyz42073 жыл бұрын
Im so sick of hearing this
@OlliWilkman3 жыл бұрын
The main way to improve the Python code would be to loop over the characters of the string ("for digit in x"), that way you don't need to make a list nor use the range function. The most "pythonic" way to write that function would probably be the one-liner "return sum(int(digit) for digit in x)", which is short and also easy to see what it does immediately.
@OlliWilkman3 жыл бұрын
Another trick to help build big number strings like that is that you can multiply a string by an integer, so 321*"9" gives you a string of 321 nines.
@АлександрКовалев-о7я3 жыл бұрын
Me: "Monkey Panic"
@АлександрКовалев-о7я3 жыл бұрын
@@OlliWilkman kzbin.info/www/bejne/rmSpg6Stgqtpaq8 I wish you a happy watching
@mortadhaalaa59073 жыл бұрын
print(sum( int(d) for d in str(sum( int(k*'9') for k in range(1, 322)) ) ))
@gudmundurjonsson43573 жыл бұрын
nice
@a-rod63363 жыл бұрын
You don't actually need to write range(1,322), range(322) does that by default
@mortadhaalaa59073 жыл бұрын
@@a-rod6336 if you run it, it gives an error because range(322) starts at zero and int(0*'9') is undefined
@a-rod63363 жыл бұрын
@@mortadhaalaa5907 that's right lol I suppose you would need to add 1 to k
@angelmendez-rivera3513 жыл бұрын
Note 2: Let a = floor[ln(n)/ln(10)] + 1, and let 0 < n < m. If 10^a | m, then digitsum(n + m) = digitsum(n) + digitsum(m). However, in the video, this was not possible to use, because -321 < 0.
@adonisnunez60783 жыл бұрын
Here is my solution by using map() and a lambda funtion: suma = sum(list(map(lambda x: 10**x, list(range(1, 322))))) - 321 suma_digitos = 0 for d in str(suma): suma_digitos += int(d) print(suma_digitos) Greetings from Dominican Rupublic, I really like this chanel.
@gudmundurjonsson43573 жыл бұрын
Tried optimising my own code with the tips from Olli Wilkman's comment: def digisum(x): s = sum([int(digit) for digit in str(x)]) return s number = 0 for i in range(1,321+1): number += 10**i - 1 print(digisum(number))
@OlliWilkman3 жыл бұрын
The square brackets around the for expression aren’t necessary. They create a list which you never use again and the sum function works with just the generator expression. Also why assign it to a variable rather than just returning it?
@OlliWilkman3 жыл бұрын
You could also write that second part as “number = sum(10**(i+1) for i in range(321))” if you want to be terse. If your loop is just doing one addition to an accumulator variable, you can usually replace it with a sum function with a loop expression.
@OlliWilkman3 жыл бұрын
Personally I’d create the number with number = int(321 * ”9”), which is a slightly cheeky way I feel.
@paulmoat70473 жыл бұрын
slightly smaller code def digsum(x): return sum(map(int, list(str(x)))) print(digsum(sum((10**(i+1)-1) for i in range(321))))
@copperfield423 жыл бұрын
13:17 flammy, you can iterate over the list itself, no need for this range thing (tho technically correct, is ugly as sin), or even over characters on the string, and a string is kind like a list of characters, so like this: def digsum(x): dig = 0 a = list(x) for n in a: dig += int(n) return dig but if you can call list on x, that mean you can iterate over it, so put it directly in the for loop: def digsum(x): dig = 0 for n in x: dig += int(n) return dig and that is the long way, the short way is using list comprehension method along side the sum function def digsum(x): return sum( int(n) for n in x ) and to eliminate the need to call str into your input beforehand, you can include into the function itself, in either of the versions def digsum(x): dig = 0 for n in str(x): dig += int(n) return dig def digsum(x): return sum( int(n) for n in str(x) )
@PapaFlammy693 жыл бұрын
Thank you David!!
@DatKid3213 жыл бұрын
Gave my own coding skills a go def digitsum(x): return(sum([int(digit) for digit in str(x)])) n = len(str(321)) print(321 - n + (n*10 - digitsum(321)))
@monkerud21083 жыл бұрын
i played you on lichess, big jens. this channel is still great
@angelmendez-rivera3513 жыл бұрын
Consider N(n) = 9 + 99 + ••• + 9•••9, with the last summand having n digits, all digits being 9. Hence N(n) = (10^1 - 1) + ••• + (10^n - 1) = 1•••10 - n, where 1•••10 has n + 1 digits, with n digits being 1. Now, this is equal to 1•••10•••0 + (1•••10 - n), where 1•••10•••0 has x digits being 1, and y digits being 0, with x + y = n + 1, and 1•••10 has y - 1 digits being 1, with y - 1 being equal to the number of digits of n. Therefore, digitsum[N(n)] = n - floor[ln(n)/ln(10)] - 1 + digitsum(1•••10 - n). 1•••10 can be written as 10 + ••• + 10^(floor[ln(n)/ln(10)] + 1), since floor[ln(n)/ln(10)] + 1 is the number of digits of n. This is also equal to 10·(1 + ••• + 10^floor[ln(n)/ln(10)])= [10^(floor[ln(n)/ln(10)] + 2) - 10]/9. Therefore, digitsum[N(n)] = n - floor[ln(n)/ln(10)] - 1 + digitsum([10^(floor[ln(n)/ln(10)] + 2) - 10]/9 - n). This is the closed form for digitsum[N(n)]. In the special case of n = 321, the results of this video arise.
@angelmendez-rivera3513 жыл бұрын
Note: the digital root of a number is not the same as the digit sum of a number. The digital root of N is 9, trivially, because the digital root is defined by iterating the digit sum function as many times as necessary until the output is a single-digit number. However, the digit sum merely adds the digits.
@Skrownia3 жыл бұрын
I see some people have mentioned the sum function, but I would also like to recommend looking into the map function it will make you able to calculate the digit sum like so "sum(map(int, x))" where x is your number as a string.
@niki33523 жыл бұрын
the digsum function can be a oneliner: def digsum(x): return sum(int(y) for y in x)
@gudmundurjonsson43573 жыл бұрын
think you need int(x) but yeah, thats the nices way to do it i think
@TheMazyProduction3 жыл бұрын
The whole program can be one line of code
@gudmundurjonsson43573 жыл бұрын
@@TheMazyProduction doesnt look that nice tho
@maypiatt37663 жыл бұрын
I think this is an AIME problem!! Except there just weren’t as many terms
@PapaFlammy693 жыл бұрын
Oh really? :0
@maypiatt37663 жыл бұрын
@@PapaFlammy69 this is the AIME I 2019 problem 1
@maypiatt37663 жыл бұрын
@@PapaFlammy69 oh and it actually was 321 terms too
@rupachakraborty36813 жыл бұрын
Great video. Btw, which IDE were you using?(You are using black theme. I see, you are a man of culture as well.)
@dizmat.mp33 жыл бұрын
Bruh lmao is that an anime mousepad
@HAL-oj4jb3 жыл бұрын
Seems you're new to the channel lol
@zvxcvxcz3 жыл бұрын
Python actually is appropriate here because of arbitrary length integers... It may be less trivial to code in other languages.
@path_selector3 жыл бұрын
great video. combines 2 of my favorite things! math and programming :)
@PapaFlammy693 жыл бұрын
:)
@AlexandrBorschchev3 жыл бұрын
you should create a recursive function too for fun
@dado0709983 жыл бұрын
Yo papa what is that figure on your desk? Looks epic.
@dozzco28273 жыл бұрын
God I've been missing these videos!, Brilliant Python Math Problem! 👍
@devincustodio22583 жыл бұрын
Hey have you thought about a recursive implementation for digsum? That would be kind of cool to write
@copperfield423 жыл бұрын
you want it recursive? yeah sure, that is easy here you go: def digsum_r(n): if 0
@devincustodio22583 жыл бұрын
@@copperfield42 that's what I wrote too
@bbblaesing3 жыл бұрын
I posted a really stupid response earlier and realized I was summing 9^n for the sum of 1 to 223. I fixed it: def summer(n,g=9): gs=0 for i in range(n): nummer=0 for j in range(i+1): nummer += g*10**j gs += nummer return gs
@bbblaesing3 жыл бұрын
answer = summer(223)
@robertstorlind23023 жыл бұрын
And we can use the theorem of the digit sum being congruent to the number mod 9 as a sanity check of the answer 342, right?
@HAL-oj4jb3 жыл бұрын
PyCharm is really a charm, my favourite IDE
@korigamik3 жыл бұрын
Try thonny
@thaihm3 жыл бұрын
Loved the lecture! 👍🏽
@mathssolverpoint60593 жыл бұрын
I solved this question in my head in 2 minutes
@Pneuma73 жыл бұрын
just what I needed, love u papa
@maxwellsequation48873 жыл бұрын
Christmas = SIR ISAAC NEWTON's birthday Ophence
@bisheshadhikari65083 жыл бұрын
Awesome video!! Really enjoyed it.
@devinwoods6413 жыл бұрын
If I’m looking to start learning more beyond highschool math where should I start with your videos?
@akshat92823 жыл бұрын
isn't a digit dum supposed to be a single digit aur recursively doing the process on the number. I'm probably wrong but that's what I heard. calculating that would be really easy. take 9 common from the original number. you'll be left with (1+11+...1...1). since you took 9 common, the number is a multiple of 9 and so the digit sum is 9. also, you can use a very basic python one liner for what you did. this wasn't a v nice program daddy but still appreciated ❤️
@angelmendez-rivera3513 жыл бұрын
No, that is a different function. What you are referencing is the digital root function, which is not the same as the digit sum function.
@Evan-ne5bu3 жыл бұрын
Man wtf, I've never been so early
@michaelempeigne35193 жыл бұрын
sum of digits of a multiple of 9, will yield a digital sum of 9; so wouldn't it make sense that it be 9 regardless of length ?
@angelmendez-rivera3513 жыл бұрын
The statement you wrote is incorrect. 99 is a multiple of 9, because 99 = 9·11, but digitsum(99) = 9 + 9 = 18, not 9. In this video, digitsum(N) = 342, not 9.
@michaelempeigne35193 жыл бұрын
@@angelmendez-rivera351 but the digital root of those numbers are 9
@angelmendez-rivera3513 жыл бұрын
@@michaelempeigne3519 The digitsum function and the digital root function are not the same. The digit root of these numbers is 9, but not the digit sum. So you are still incorrect per my comment.
@mehulborad24003 жыл бұрын
10:09 Programmers be like : it and IDE not a EDITOR for God's sake
@chicken28963 жыл бұрын
where did you buy your blackboard and for how much?
@PapaFlammy693 жыл бұрын
some 1.5k from some german manufacturer ^^'
@chicken28963 жыл бұрын
@@PapaFlammy69 Thanks 🐐
@roeesi-personal3 жыл бұрын
I know this video is old but one liners are always nice so I want to share mine with everyone who will see this comment. sum(int(d) for d in str(sum(int('9'*j) for j in range(1, 322)))) It's not very efficient, but it's a simple python one liner, what did you expect?
@gapdragon013 жыл бұрын
"Three hundred twenty FIRST power"!!!!!!
@PapaFlammy693 жыл бұрын
:^D
@Chr0nalis3 жыл бұрын
Try out the visual studio code dark plus colorscheme for Pycharm. Nicest looking one that I've used so far. Darkula sucks balls.
@raiymshuak3 жыл бұрын
I think I saw this in the AIME one of the last years
@matron99363 жыл бұрын
Hey saw ya doing it in discord, nice lemme watch dat video see if I solved it right.
@a_llama3 жыл бұрын
I saw this problem on mu prime math!
@alwysrite3 жыл бұрын
please post more python videos
@69erthx11383 жыл бұрын
If this vid doesn't PROVE that arithmetic is the most difficult kind of mathematics, I don't know what does?
@angelmendez-rivera3513 жыл бұрын
...it doesn't prove that. This exercise was surprisingly easy to solve.
@69erthx11383 жыл бұрын
@@angelmendez-rivera351 My post was a joke😁.
@brettstafford96653 жыл бұрын
I solved this in like 3 minutes.
@ricardoparada53753 жыл бұрын
Relatable meme lmao
@MrRyanroberson13 жыл бұрын
ok wtf youtube unsubscribed me from your channel??
@PapaFlammy693 жыл бұрын
wtf? why does it do that? ;_;
@MrRyanroberson13 жыл бұрын
@@PapaFlammy69 i don't even know! i noticed was because it was suggesting your vids to me... as a "new channel" to check out for some reason. honestly though i'm afraid for the channels i didn't notice...
@PapaFlammy693 жыл бұрын
well...
@djcoolvibes3 жыл бұрын
And if you keep applying digitsum, you will always end up with 9
@angel-ig3 жыл бұрын
Yeah, because "infinite" digit sum of n is n mod 9
@ezras79973 жыл бұрын
Can you do tjis?!
@АлександрКовалев-о7я3 жыл бұрын
def censored_sum(n): ---> s = 0 while n != 0: --2> s += n % 10 n //= 10
@АлександрКовалев-о7я3 жыл бұрын
if I understand your problem it right
@Observer_detector3 жыл бұрын
dude is that Putnam problem? intersting
@PapaFlammy693 жыл бұрын
Seems to be an AIME Problem! :)
@АлександрКовалев-о7я3 жыл бұрын
Maybe, they not understand, that you solve the genial challenges, as Mathmann, but in our "world" we can solve ones another way?
@АлександрКовалев-о7я3 жыл бұрын
10:50
@maxmusterman33713 жыл бұрын
daim i just cant watch your videos without headset because the cringe amount is too high in the first 30 seconds