algorithms – List the terms resulting from the decomposition of a number by divisions repeated by 2

Consider a natural number $ n> $ 1. We express it as $ lfloor frac n 2 rfloor + lceil frac n 2 rceil $. We repeat the process for each of the two terms until all the terms are 1 or 2. For example $ 9 = 4 + 5 = 2 + 2 + 2 + 3 = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 2 $.

There will be $ 2 ^ { lfloor log_2 n rfloor} $ terms because the decomposition forms a complete binary tree of height $ lfloor log_2 n rfloor $.

I'm looking for an iterative form of this recursive process. The enumeration $ a_0 = 0, a_ {i + 1} = left lfloor frac {(i + 1) cdot n} {2 ^ { lfloor log_2 n rfloor}} right rfloor – a_i $ approximates because it fulfills the following conditions: (a) each term is worth 1 or 2; b) the sum of the first $ 2 ^ { lfloor log_2 n rfloor} $ terms is $ n $. But the elements are not identical to the form of recursive decomposition.

Any help would be welcome. Thank you!

Expected value to get number 1 three times when you roll the dice

I fight with only one practice. The question is what is the expected value to get the number 1 three times when rolling a dice (6 sided) three times?

For a die, it is 1/6 * (1 + 2 + 3 + 4 + 5 + 6) = 3.5.

When you roll a dice three times, what is the expected value to get number 1 three times?

Golden number of a circle and square

φ is the golden ratio. In the given figure, how can we prove that the perimeter of the circle is not equal to the perimeter of the square.

enter description of image here

I am confused as it is not clearly described in the figure. Then how can we prove it.

dnd 5th – How do I determine the number of spell slots I have during multiclassing?

You determine your available spell locations by adding all your levels in the bard, cleric, druid, sorcerer and sorcerer classes, half of your levels (rounded down) in the paladin and ranger classes, and one third of your combatant levels or rogue (rounded down) if you have the Eldritch Knight function or the Arcane Trickster function. Use this total to determine your spell locations by consulting the Multiclass Spellcaster table.

So in this case, your caster level is 8 and would have 4 first level spell locations, 3 second level locations, 3 third level locations and 2 fourth level locations.

But what about my Warlock levels?

The same section on multiclass orthographic dissemination also reads

If you have both the Spellcasting class functionality and the Pact Magic class functionality of the warlock class, you can use the spell slots you earn from the Pact Magic functionality to cast spells you know or have prepared from classes with the Spellcasting class feature, and you can use the spell locations you earn with the class spellcasting function to cast warlock spells you know.

This basically means that these niches are completely independent of the others. They are not affected by the rest of your levels. However, you can still cast your warlock spells with the locations of your Wizard, Fighter, Rogue, and Paladin classes, and you can use your warlock spell locations (which recover on a short break!) To cast your spells from these classes. They are separate but compatible.

So your total number of spell slots, after adding your 4 levels in Warlock, is 4 first level spell slots, 5 second level slots, 3 third level slots and 2 fourth level slots. And two of these second level slot machines recover on a short rest.

For more information on how many spells you know, check out this QA.

terminal – cron task: copy a number from a web page and paste it into a specific cell in the numbers app

I want to copy a number from a web page and paste it everyday into the cell of a number at 7:55 a.m.

I first imagined that I could download this page and search for it to get the number with a python script, then copy and paste this number into different cells in a column every day

(i don't know anything about mac and terminal but i'm used to programming with python and i did a few things on linux bash)

validation – What is the optimal number of digits for a verification text message?

It is a validation process in an application. The user has downloaded the application, he is invited to validate his account via an SMS. So they have to check their messages and then enter a code in the app.

When you receive a text message sent to the phone number you already entered to validate your account, I know that iCloud uses 4 digits and certain uses 6. In my mind, 4 is better because it is easier to remember. 39; a block only of 6 digits. I can easily remember 4432 but more difficult to remember 443 267 by jumping between the messaging app and the validating app. I understand that there is a security issue, but since they entered the number themselves and received the text, the security should be high, even with 4 digits.

So here's the question: who will lead to more conversion and does anyone have articles on this?

Personalization – You want to add text in front of the display of the number of pages in a set

I have the usual number of pages at the bottom of my pages which displays a square with a number 1,2,3,4 I would like to add some text in front of this set of numbers such as "Pages>"
Can someone tell me where I can put this text, I can't find any way to do it. I realize that the text must evolve in unison with the numbers since the pages are added from time to time and this lengthens the list of numbers.
Thank you

precision and accuracy – How to increase the number of decimal places for this code?

How to increase the number of decimal places for

f1 = Map(Flatten@*First)@MeshPrimitives(#, 1) &;
f2 = Flatten(Flatten(f1@CantorMesh(13)));
f(x_) := x^(1/5)
N(Total(f@f2)/Length(f2), 10)

I get six decimal places instead of 10.


How do we fix it?

number theory – (a1, are quadratic residues mod p1,, how to find a quadratic residue mod N = p1 *

If this is not possible, is there a way to prove that there is a one-to-one correspondence between (a1, and the quadratic residuals of N? If x2 -a = 0 mod N then x2 -a = 0 mod P and by CRT each (a1, corresponds to a different one therefore the number of residues in N must be <= the possibilities for (a1, But I don't know why it must be >= also.

python 3.x – Given an array, find the integer that appears an odd number of times. There will always be a single integer that appears an odd number of times

def find_it(seq):
    counter = {}

    for num in seq:
        if num in counter:
            counter(num) = 1

    for k in counter:
        if counter(k) % 2 != 0:
            return counter(k)


test.assert_equals(find_it((20,1,-1,2,-2,3,3,5,5,1,2,4,20,4,-1,-2,5)), 5)
test.assert_equals(find_it((1,1,2,-2,5,2,4,4,-1,-2,5)), -1); 
test.assert_equals(find_it((20,1,1,2,2,3,3,5,5,4,20,4,5)), 5);
test.assert_equals(find_it((10)), 10);
test.assert_equals(find_it((1,1,1,1,1,1,10,1,1,1,1)), 10);
test.assert_equals(find_it((5,4,3,2,1,5,4,3,2,10,10)), 1);

So he wants me to know which integer appears an odd number of times in a list, so I created a dictionary and counted the values ​​of the number of times it was counted and I all noted, but the only thing i need to do is print the key & # 39; 5 & # 39; which has been counted 3 times but I don't know how to return it. I am a beginner, so I may be overestimating this problem and I am sure there is an easier way to solve this problem, but I would also like to know how to solve this problem than I have . Thank you!