Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Nested for loop expressed in math

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
AIva1110
Advanced Cheater
Reputation: 0

Joined: 16 Sep 2009
Posts: 56
Location: The Void

PostPosted: Fri Jan 08, 2010 5:37 pm    Post subject: Nested for loop expressed in math Reply with quote

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
View user's profile Send private message
Caelestis
Expert Cheater
Reputation: 0

Joined: 03 May 2007
Posts: 153

PostPosted: Fri Jan 08, 2010 7:21 pm    Post subject: Reply with quote

a^2^n^2

where a is the initial value of the variable

Analysis

First you start by squaring 'a'

Code:
a := a * 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

Code:
for j := 1 to n do


a^2^n

then you set 'a' to itself times itself

Code:
for i := 1 to n do


a^2^n^2


Last edited by Caelestis on Fri Jan 08, 2010 7:45 pm; edited 4 times in total
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

Joined: 09 May 2003
Posts: 25859
Location: The netherlands

PostPosted: Fri Jan 08, 2010 7:40 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
AIva1110
Advanced Cheater
Reputation: 0

Joined: 16 Sep 2009
Posts: 56
Location: The Void

PostPosted: Fri Jan 08, 2010 8:48 pm    Post subject: Reply with quote

Thanks for explanation and code, appreciate it. I had too much of this stuff today.
_________________



Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites