| View previous topic :: View next topic |
| Author |
Message |
AIva1110 Advanced Cheater
Reputation: 0
Joined: 16 Sep 2009 Posts: 56 Location: The Void
|
Posted: Fri Jan 08, 2010 5:37 pm Post subject: Nested for loop expressed in math |
|
|
for i := 1 to n do
for j := 1 to n do
begin
a := a * a;
end;
This is pascal syntax, if somebody doesn't know begin and end; is like {} code segment in C, := is asignment operator so a changes after every execution for example 1) 2*2 = 4 2) 4*4 = 16 and so on. For i:= to n do is a simple for loop which executes 2 times if n=2.
How would this look like in mathematical expresion, let's say n=2 ,a = 2 then the result is a^16.
I tried to solve this for some time and wondered if anybody here would know the logic behind it.
_________________
|
|
| Back to top |
|
 |
Caelestis Expert Cheater
Reputation: 0
Joined: 03 May 2007 Posts: 153
|
Posted: Fri Jan 08, 2010 7:21 pm Post subject: |
|
|
a^2^n^2
where a is the initial value of the variable
Analysis
First you start by squaring 'a'
a^2
then you do a loop to set 'a' equal to 'a' times current val of 'a' n times which would be a^2*a^2... n times = a^2^n
a^2^n
then you set 'a' to itself times itself
a^2^n^2
Last edited by Caelestis on Fri Jan 08, 2010 7:45 pm; edited 4 times in total |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25859 Location: The netherlands
|
Posted: Fri Jan 08, 2010 7:40 pm Post subject: |
|
|
x=a^(2^(n^2));
edit, what Caelestis said yes
pascal code that returns the same results:
| Code: |
uses math;
a:=power(a,power(2,power(n,2)));
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
AIva1110 Advanced Cheater
Reputation: 0
Joined: 16 Sep 2009 Posts: 56 Location: The Void
|
Posted: Fri Jan 08, 2010 8:48 pm Post subject: |
|
|
Thanks for explanation and code, appreciate it. I had too much of this stuff today.
_________________
|
|
| Back to top |
|
 |
|