C++ to Mathematics

Hi , is it possible to transform the following code to math

int F( int n )
{
int r=0;
int mid=n/2;
for( int i=0 ; i<n ; i++)
{
if( i<mid) r+=1 ;
if( i==mid) r*=2 ;
if( i>mid) r=pow(r,3) ;
}
return r ;
}

and is this correct ? www.dirbax.com/inventions/dimd-dynamic-intelligent-mathematical-design-/practical-example-1.html

thanks
Last edited on
Umm, I didn't understand a word from the link you gave.

As far as that function F goes, it will return, according to me,

(n-1)^(3^((n-1)/2)) if n is odd and

n^(3^(n/2-1)) if n is even.

May I ask, why would you wanna write such a function?
The example OP posted seems to be meant for a language called MIMD. It's not directly related to mathematics.
Strange function...unless I'm mistaken:

F(n) = 0, for any n < 2

F(n) blows up like crazy, when n > 1.
Thanks tition , would you mind to explain me how did you find it ?
I carefully traced your code -

By the way, at your site, if you want to impress people better, don't put that PI equals approximately 22/7. It looks way too simple. Better say:

Approximately,
PI ~ 3,14159265.
More Precisely,
PI = and then give one of the exact formulas you can find, for example, in
http://en.wikipedia.org/wiki/Pi

What about this function


int F( int n , int a, int b )
{
int r=0;
int mid=(a+b)/2;
for( int i=0 ; i<n ; i+=2, mid++)
{
if( i<mid ) r++ ;
if( i<mid && i>a ) r-- ;
if( i==mid ) r=r/2 ;
if( i>mid || i<b ) r=sqrt(r) ;
}
return r ;
}
Last edited on
Topic archived. No new replies allowed.