Questions tagged [exponentiation]

Anything related to the exponentiation operation, i.e. the process of computing the power of a number, and the corresponding syntax, semantics, constraints and implementation in programming languages.

Exponentiation is the process of raising a number to the nth power, (xn). Mathematically, it is denoted by superscripts, where the superscripted number is the exponent - xy.

However, since many text editors do not support superscripts, an alternative notation is used in code that uses exponentiation - typically a caret (x^y) or two asterisks (x**y). Other programming languages do not support symbolic operators for exponentiation, and rely on the pow function to calculate the exponent.

Please remember that the caret notation ^ may be used for bitwise XOR instead, and some languages does not support a built-in exponentiation operator.

See more

  • : a function that performs exponentiation. Namely, pow(a, b) calculates ab.
  • : do not assume that the ^ operator represents exponentiation. Many languages treat the ^ operator as bitwise-xor instead.
  • : The function ex, base-e exponentiation.
  • : Describes a type of curve produced by an exponent. Here, the the base is constant, and the variable is the exponent - and it grows extremely fast.
  • Wikipedia article for nore information about exponents and their identities.
368 questions
-3
votes
3 answers

Want to minimize my code so it consumes time less than 1 sec. It uses concept of modular exponentiation .Correct output but exceeding time limit

The below code is to calculate 2^n where n is equal to 1 <= n <= 10^5. So to calculate such large numbers I have used concept of modular exponentian. The code is giving correct output but due to large number of test cases it is exceeding the time…
-3
votes
1 answer

Largest Power: Find x and y with largest possible y for a given number n where x^y = n

I want to find the base and exponent for a given number such that exponent is the largest.For example: 16 can be expressed as 2^4, 4^2. The solution is 2^4 as 4 is the highest possible exponent. So far, I have the following solution; I'd like to…
-3
votes
1 answer

Exponentiaion program

Question is this Nancy hates any and every string that contains the number "13". Clouseau wants to gift her a string and is looking over his options, ofcourse he would never pick a string that has "13" as a substring. Tell Clouseau the total number…
-3
votes
4 answers

Modular exponentiation function returns the wrong int value

I got a modular exponentiation function in C which looks like this. int modexp(int m, int e, int n) { printf("%i\n", m); printf("%i\n", e); printf("%i\n", n); printf("\n"); if(e == 0) { return 1; } if(e%2 ==…
tpei
  • 671
  • 9
  • 26
-4
votes
1 answer

Why is 2 raised to 4 equal 10?

I was looking into bitwise operators in rust, and I found that println!("{:X}", 1 << 4); prints out 10, but 2^4 should equal 16. Further experimentation, using powers: let base: i32 = 2; for i in 1..=5 { print!("{:X} ", base.pow(i)); } will…
-4
votes
3 answers

Millionth Fibonacci Number - Numpy Python Implementation

I am trying to implement a code which works for retrieving Millionth Fibonacci number or beyond. I am using Matrix Multiplication with Numpy for faster calculations. According to my understanding it should take O(logN) time and worst case for a…
user14899645
-6
votes
1 answer

Python Matrix Exponentiation

I would like to use Python 2.x or 3.x to raise a 2x2 matrix that is initially 0 1 1 1 to the exponent of 1019 or less. (That is, let M = my matrix, M1019). However, I don't want to use numpy. (By the way, this is for a fibonacci generator )
bobhob314
  • 16
  • 1
  • 9
-8
votes
5 answers

How do I raise every element in a list to its corresponding index number?

So if the input is [3, 2, 5], the output would be [1, 2, 25], and if the input was [5, 10, 20], the output would be [1, 10, 400] (5^0, 10^1, 20^2)
1 2 3
24
25