## c++ – While allocating appropriate amount of space for big integers why does the needed space increase with the integer’s value?

I am trying to learn about integer overflows in C and C++ from a website. In its tutorial, it uses these lines of code:

info_size = (*n * sizeof(int)); //value of the number multiplied by sizeof(int), assumed to be 4 bytes
buffer = malloc(info_size)


where *n is the integer we are trying to store. It gives an example by storing 24 which leads to it allocating 96 bytes. It then goes on to say that if the multiplication exceeds 2147483647 (2^31 – 1), since info_size is an integer, it would recount and it may come out as a negative number.

Even if I were to store something big like 2147483647 shouldn’t it be just 32 bits of 1, therefore only 4 bytes?

## Suppose $p$ is a prime number. Prove that, for all integers $x$, $(p-3)x^{p^3}+x^{p^2}+x^p+x$ is divisible by p .

I know that $$x^p$$ is congruent mod p to x, but I do not know how this applies to (p-3), $$x^{p^3}$$ and $$x^{p^2}$$ respectively.

Some help in a detailed proof would be greatly appreciated thanks!

## nt.number theory – Can a product of Cohn matrices over the Eisenstein integers with non-zero, non-unit coefficients be a Cohn matrix?

For $$k > 1$$, is it possible that $$begin{pmatrix} a_1 & 1 \ -1 & 0 end{pmatrix}begin{pmatrix} a_2 & 1 \ -1 & 0 end{pmatrix}ldots begin{pmatrix} a_k & 1 \ -1 & 0 end{pmatrix} = pm begin{pmatrix} b & 1 \ -1 & 0 end{pmatrix}$$ if $$a_1,a_2,ldots a_k,b$$ are Eisenstein integers and $$|a_i| > 1$$ for $$i=1,2,ldots k$$?

If the Eisenstein integers are replaced with the Gaussian integers, this is possible.
$$begin{pmatrix} 3 & 1 \ -1 & 0 end{pmatrix}begin{pmatrix} 1 – i & 1 \ -1 & 0 end{pmatrix} begin{pmatrix} 1 + i & 1 \ -1 & 0 end{pmatrix}begin{pmatrix} 1 – i & 1 \ -1 & 0 end{pmatrix} begin{pmatrix} -2 & 1 \ -1 & 0 end{pmatrix} = -begin{pmatrix} i & 1 \ -1 & 0 end{pmatrix}$$

This problem came up in my research; I am primarily interested in the case where $$b = (pm 1 pm sqrt{-3})/2$$, but I suspect that there might not be a solution for any choice of $$b$$.

I originally asked this question on math.stackexchange (https://math.stackexchange.com/q/3903567/202799), but it seems to be more difficult than I first thought.

## Assuming two integers are odd

Is there a way to assume both n and k are odd in Mathematica?
Assuming({n > 0, k > 0}, Exp(-I*((Pi)/2)*(n^k)) // FullSimplify)

## an inequality over integers – Mathematics Stack Exchange

Thanks for contributing an answer to Mathematics Stack Exchange!

But avoid

• Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.

## How does adding a primitive root of unity to a number field effect the ring of integers?

We know that if $$xi$$ is a primitive $$n^text{th}$$-root of unity, then the ring of integers $$mathcal{O}_{mathbb{Q}(xi)}$$ of $$mathbb{Q}(xi)$$ is $$mathbb{Z}(xi)$$.

Can we generalise this result to say much about the ring of integers $$mathcal{O}_{K(xi)}$$ of $$K(xi)$$, where $$K / mathbb{Q}$$ is some finite algebraic extension?

Is it the case that $$mathcal{O}_{K(xi)} = mathcal{O}_{K}(xi)$$?

If this is not generally true, do we have a characterisation of circumstances where this may hold?

Failing that, do we have an alternate description of $$mathcal{O}_{K(xi)}$$ in terms of $$mathcal{O}_{K}$$?

I would appreciate any comments, or even just a reference for these kinds of results.

## How to use Apply command to find the product of the squares of a list of integers

A] Create a list of the first 30 positive odd integers;
B] Find the product of the squares of these integers by utilizing the Apply command.

{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100}

{1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35,
37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59}

I’m stuck on how to do part B.

## python – Randomly selected integers from predetermined lists add up to specific input value

Hello im trying to write a Python code that selects integers from arrays up to a certain value.

I wrote this code however the code uses every list once (as is intended). But sometimes it is still below the input value and has no more options to choose from.

For example if i say WantedNumber is 15 and it picks 4 from listC and 5 from listA, it then has no more options for a correct answer in listB.

or sometimes it picks 1 from every list and then it has no more lists to choose from cause it used all of them already.

How can I make it select a random sequence of integers that adds up to WantedNumber

Note: ”similar questions” are always about completely random numbers adding up to input value. But I don’t want random numbers, I want randomly selected predetermined numbers from my lists.

import random

listA = (1,2,3,4,5)
listB = (1,2,3)
listC = (1,2,4,7)

All = (listA,listB,listC)

x = 0

while x < int(WantedNumber):
print(x) #this prints the new x value with the new Random2 added up

Random1 = random.choice(All)
Random2 = random.choice(Random1)

print(Random1) #this prints which variable of the list it chose
print(Random2) #this prints which integer from the array from Random1 it chose
index = All.index(Random1)
All.pop(index)

Y = int(x) + int(Random2)

if Y<=int(WantedNumber):
x=Y
$$$$


## 8 – Symbols for certain locales missing in multilingual sites when using the number formatter moule to format integers to ordinal numbers

I was looking for a module that converts integers entered in a field into ordinal numbers, For eg 22 to 22nd and 33 to 33rd.

I ran into the https://www.drupal.org/project/number_formatter and it works

The module works really well for English (en) converting 1 to 1st, 2 to 2nd, and so on.

However, for other languages like Arabic with locale ‘ar’ it is not converting accurately. The symbol seems to be missing and instead, we get a ‘.’. The same happens for ru as well. “

I debugged the module and I found that it was using the core PHP class NumberFormatter.

use NumberFormatter as IntlNumberFormatter;

$language =$this->languageManager->getCurrentLanguage()->getId();
$numberFormatter = new IntlNumberFormatter($language, $this->settings('style'));  Dumping the$numberFormatter led me to the following output.

^ NumberFormatter {#2773 ▼
locale: "ar"
pattern: """
%digits-ordinal:

0: =#,##0=.;

-x: −>%digits-ordinal>;

"""
attributes: {▶}
text_attributes: {▶}
symbols: {▶}
error_code: 16
error_message: "Error getting symbol value: U_UNSUPPORTED_ERROR"
}


I tested this code separately and found that the problem exists outside the module and is likely a core PHP bug. Is there something additional we need to do get this fixed?

## Encoding two 6-bit positive integers compactly

Is it possible to encode two 6-bit wide positive integers a and b guaranteed to be in (0, 63) in a way that a and b are recoverable — in fewer than 12 bits? We could obviously concatenate the binary representations (a << 6 | b)`? The scheme would have to allow any two arbitrary values within the given range. Can we do better than 12 bits?