numbers

How to allow only WhatsApp format numbers in a regex?

纵饮孤独 提交于 2021-01-20 08:52:34
问题 so I'm trying to make this Regex allow this the Dash symbol - For Example this Phone Number is not matching right now +212 659-123456 So I need someone to help me change the Regex to allow it please Here is the Regex: ^\+(?:[0-9]\x20?){6,14}[0-9]$ Because I am trying to only accept the format that is used by WhatsApp and some numbers might have multiple spaces or multiple Dashes. Also the Plus sign has to be mandatory Here some more examples of the format on WA. +96274567123 +967773-123-123

How to allow only WhatsApp format numbers in a regex?

雨燕双飞 提交于 2021-01-20 08:52:24
问题 so I'm trying to make this Regex allow this the Dash symbol - For Example this Phone Number is not matching right now +212 659-123456 So I need someone to help me change the Regex to allow it please Here is the Regex: ^\+(?:[0-9]\x20?){6,14}[0-9]$ Because I am trying to only accept the format that is used by WhatsApp and some numbers might have multiple spaces or multiple Dashes. Also the Plus sign has to be mandatory Here some more examples of the format on WA. +96274567123 +967773-123-123

Truly Tail-Recursive modInverse() in Prolog

半城伤御伤魂 提交于 2021-01-05 11:50:56
问题 Rosetta code delivers me the following code snippet for modinv/3. It does calculate extended GCD via egcd/4 and then derives from it modinv/3: egcd(_, 0, 1, 0) :- !. egcd(A, B, X, Y) :- divmod(A, B, Q, R), egcd(B, R, S, X), Y is S - Q*X. modinv(A, B, N) :- egcd(A, B, X, Y), A*X + B*Y =:= 1, N is X mod B. Example queries: ?- modinv(42, 2017, N). N = 1969. ?- modinv(42, 64, X). false. There is a slight problem with the solution. It is not tail recursive. Namely the (is)/2 is the last call of

Calculate very large number using python

*爱你&永不变心* 提交于 2021-01-05 09:07:13
问题 I'm trying to calculate (3e28 choose 2e28)/2^(3e28). I tried scipy.misc.comb to calculate 3e28 choose 2e28 but it gave me inf. When I calculate 2^(3e28), it raised OverflowError: (34, 'Result too large'). How can I compute or estimate (3e28 choose 2e28)/2^(3e28)? 回答1: Use Stirling's approximation (which is very accurate in the 1e10+ range), combined with logarithms: (3e28 choose 2e28) / 2^(3e28) = 3e28! / [(3e28 - 2e28)! * 2e28!] / 2^(3e28) = e^ [log (3e28!) - log((3e28-2e28)!) - log(2e28!) -

Calculate very large number using python

蹲街弑〆低调 提交于 2021-01-05 09:04:51
问题 I'm trying to calculate (3e28 choose 2e28)/2^(3e28). I tried scipy.misc.comb to calculate 3e28 choose 2e28 but it gave me inf. When I calculate 2^(3e28), it raised OverflowError: (34, 'Result too large'). How can I compute or estimate (3e28 choose 2e28)/2^(3e28)? 回答1: Use Stirling's approximation (which is very accurate in the 1e10+ range), combined with logarithms: (3e28 choose 2e28) / 2^(3e28) = 3e28! / [(3e28 - 2e28)! * 2e28!] / 2^(3e28) = e^ [log (3e28!) - log((3e28-2e28)!) - log(2e28!) -

Change numbers to letters in a int array and return String in java

让人想犯罪 __ 提交于 2021-01-04 07:27:25
问题 I have an int array (b[]) with a random length and random integers. I want to leave integers lower than 9 to how they are, i want to change the numbers 9-35 to letters A-Z . and i want do put () around all numbers higher than 35 . So b[] = {1,10,36} would generate a String 1A(36) . My try: int b[] = {99, 2, 3, 4, 5, 10, 35, 24}; //sample input char[] hilfsarray = new char[b.length]; char[] alphabet = "ABCDEFGHIJKLMNOPQRSTUVW".toCharArray(); for (int k = 0; k < hilfsarray.length; k++) /

Adding thousand separator while printing a number [duplicate]

五迷三道 提交于 2021-01-04 02:31:04
问题 This question already has answers here : How to print number with commas as thousands separators? (27 answers) Closed 7 years ago . I don't really know the "name" for this problem, so it might be a incorrect title, but the problem is simple, if I have a number for example: number = 23543 second = 68471243 I want to it make print() like this. 23,543 68,471,243 I hope this explains enough or else add comments. Any help is appreciated! 回答1: If you only need to add comma as thousand separator and

Adding thousand separator while printing a number [duplicate]

烂漫一生 提交于 2021-01-04 02:30:40
问题 This question already has answers here : How to print number with commas as thousands separators? (27 answers) Closed 7 years ago . I don't really know the "name" for this problem, so it might be a incorrect title, but the problem is simple, if I have a number for example: number = 23543 second = 68471243 I want to it make print() like this. 23,543 68,471,243 I hope this explains enough or else add comments. Any help is appreciated! 回答1: If you only need to add comma as thousand separator and

WhatsApp Phone number Regex [duplicate]

牧云@^-^@ 提交于 2020-12-15 05:25:34
问题 This question already has answers here : Regex | how to allow only Whatsapp formats (2 answers) Closed 7 days ago . I'm trying to make this Regex allow this symbol - For Example this Phone Number is not matching right now +212 659-639217 So I need some one to help me change the Regex to allow it please Here is the Regex: ^\+(?:[0-9]\x20?){6,14}[0-9]$ 回答1: How about this one? ([+]*\d{3,})*\s?\d{3}[-]?\d{6} Optional plus sign Optional space (between country code and the rest) Optional dash

javascript rotate array elements [duplicate]

半腔热情 提交于 2020-12-12 06:17:18
问题 This question already has answers here : Rotate the elements in an array in JavaScript (31 answers) Closed 2 years ago . Hello, everybody, I have this task: I have an array [4,7,3,6,9] and I have to make an array like this: [4,7,3,6,9] [9,4,7,3,6] [6,9,4,7,3] [3,6,9,4,7] [7,3,6,9,4] I have to make a program where array is rotating even if I add a new item to an array it should change accordingly. I am total newbie at JS, 1 week or so, here is my current try: var numbers = [4, 7, 3, 6, 9];