Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Bug ???


Artur schrieb:
> Why doesn't work:
> a={};Do[k=n^2-(Floor[n^2(2/3)])^2;If[k=0,
> AppendTo[a,{k,n^2}]],{n,1,1000}];a
> but working
> a={};Do[k=n^2-(Floor[n^2(2/3)])^2;If[k<1,
> AppendTo[a,{k,n^2}]],{n,1,1000}];a
> 
> Artur Jasinski, Poland
> 
> 

Hi Artur,

1. If [k=0,...] assigns 0 to k and becomes If[0,...] and 0 != True.
2. k<1 is a completely other test than k==0.

But wouldn't it be much easier to use
{{0, n^2}} /. ToRules @ Reduce[Floor[2n^2/3] == n > 0, n, Integers]
to get the same result?
(and is it necessary to use a CAS for this anyway)?

Peter


  • Prev by Date: Re: Multiple nests?
  • Next by Date: Can Integrate[expr,{x,a,b}] give an incorrect result?
  • Previous by thread: Re: Bug ???
  • Next by thread: Re: help with polynomial solutions