Printing only integer values for some equation using MATHEMATICA.

  • Mathematica
  • Thread starter 76Ahmad
  • Start date
  • #1
48
0

Main Question or Discussion Point

Hello every one, I need help on some mathematica run program.

Suppose the following:

1) 2=<t=<1000
2) r=3+2Sqrt[2]
3) k=(r^t+r^(-t)-20)/4
4) n=2k+4
5) x=n/2-(r^t-r^(-t))/2Sqrt[2]

I need to run the program For[t=2,t=<1000,t++
and only print if it found any integer values of (k,n,x)

please help, thanks
 

Answers and Replies

  • #2
1,069
29
r = 3 + 2Sqrt[2];
For[t = 2, t <= 1000, t++,
k = (r^t + r^(-t) - 20)/4;
If[IntegerQ[k], Print["k=", k]];
n = 2k + 4;
If[IntegerQ[n], Print["n=", n]];
x = n/2 - (r^t - r^(-t))/2Sqrt[2];
If[IntegerQ[x], Print["x=", x]];
]

And this prints nothing because every value has high powers of 3+2 Sqrt[2]
 

Related Threads on Printing only integer values for some equation using MATHEMATICA.

Replies
1
Views
2K
Replies
3
Views
2K
Replies
9
Views
6K
Replies
2
Views
5K
Replies
5
Views
3K
Replies
6
Views
10K
Replies
1
Views
2K
Top