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
-1
votes
1 answer

Squaring and totaling in java

So the challenge is to prompt the user to enter an integer value "count". Next prompt them to enter "count" more values. Then square each value entered and add it to a main value sum.Then display the sum of the square of all the numbers entered. …
Sean Marc
  • 13
  • 3
-1
votes
2 answers

Algorithm of A^B(A power B) for Big numbers

Can you help me to find Algorithim of A^B(A power B) for big numbers( say up to 9*10^18) without using any libraries(Like java Math.Biginteger)? I know JAVA, so it would be great if the code written in java.
-1
votes
4 answers

Raising an integer to the Xth power

In response to this prompt: Write a function integerPower( base, exponent ) that returns the value of base exponent. For example, integerPower( 3, 4 ) == 3 * 3 * 3 * 3. Assume that exponent is a positive, nonzero integer and base is an integer. The…
setup_741
  • 1
  • 1
-1
votes
2 answers

Fibonacci - Divide and conquer algorithm

#include using namespace std; int main() { int i=1; int j=0; int k=0; int h=1; int t=0; int n; cin>>n; while (n) { if (n%2) { t=j*h; j=i*h+j*k+t; i=ik+t; …
-2
votes
3 answers

How to calculate the sum of the sequence without using built-in functions for exponentiation?

I need to calculate the sum of the sequence in Python but I can't use the built-in functions for exponentiation. It means I can't use ** and pow(). I have to create my own function for that. So I created the function for exponentiation but it works…
Minimalist
  • 79
  • 1
  • 6
-2
votes
1 answer

How can I calculate 2^n+2^n-1+...+2^k mod 2^60 in C++, where the value of 2^i can be very big?

For a programming question I have to print the expression 2^n+2^n-1+...+2^k mod 2^60, where 1<=k
-2
votes
1 answer

How to calculate power index in CMake file

I am working on CMake unit test cases that is using ctest. I am having one question here. Some part of my CMake is as below: set(size_w 32 ) set(powerof2_w 5 ) foreach(size ${size_w}) foreach(pwr_of_2 ${powerof2_w}) ... …
jailaxmi k
  • 89
  • 3
  • 11
-2
votes
3 answers

How to efficiently compute large powers of 2?

I'm trying to calculate, for 0 < n ≤ 10⁹, the value of re=(2^n)%1000000007 I wrote this code: int main() { int n,i,re=1; scanf("%d",&n); for(i=0; n>i; i++) re=(2*re)%1000000007; printf("%d",re); } When n is 10⁹, my code takes too…
Mostafa
  • 1
  • 4
-2
votes
2 answers

Implement x^(e) in Extended Pascal, without using exponentiation operators

Part of a Pascal ISO 10206 program I am building, requires me to implement a function to exponentiate a real number (x) to Eulers number (e), without using any exponentiation functions already included in Pascal(**,pow,exp...). I have been trying…
-2
votes
1 answer

How to implement modular exponentiation that requires at most double the bytesize of the number that is to be modularly exponentiated in C?

In other words is there such an algorithm for : // powmod(m,e,n) = m^e % n unsigned long long powmod(unsigned long m, unsigned long e, unsigned long long n) that it doesn't overflow for let's say where m = 2^32 - 1, e = 3, n = 2^64 - 1 without gmp…
Nae
  • 14,209
  • 7
  • 52
  • 79
-2
votes
2 answers

Parse error: syntax error, unexpected '*'

My code: And when I am running it, it gives the following error…
Yash Kumar Verma
  • 9,427
  • 2
  • 17
  • 28
-2
votes
2 answers

Java-matrix exponentiation to find the Fibonacci sequence

wondering how to map this to code as thats all i have to go off of http://puu.sh/fKuyF/815515d66f.png
Thorx99
  • 38
  • 1
  • 2
  • 9
-2
votes
1 answer

power numbers on assembly intel 8086

I have to power nums in assembly (intel emu 8086). How can I power (Exponentiation) 2 digits nums in assembly? Must I save the result in array? What is the length of the larget possible result? (99^99) Thanks, Ori
-2
votes
1 answer

Repetitive squaring (python)

I implemented the exponentiation by squaring algorithm in Python (x,n)=(input(),input()) def exp_itr(x,n): r=1 while n!=0: if n%2==1: r=r*x n=n-1 x=x*x n=n/2 return…
Evyatar Elmaliah
  • 634
  • 1
  • 8
  • 23
-3
votes
1 answer

how do I use modular expression/ working with large intergers

I want to make a program that calculate the the populations after x years. where the pop in 2002 is 6.2 billion people and increases 1.3 % each year. The formula I will use is population = ((1.013)**x) * 6.2B How do I make 6.2B easier to work…
delgeezee
  • 103
  • 1
  • 7
1 2 3
24
25