Hi,

On 2014-07-27, Matematica pentru toți <davio...@gmail.com> wrote:
> I tried:
>
> while x<10:
>     if (124+5*x)%2==0:
>         print x,
>         x=x+1
>

I suppose you need to define an initial value for x first (i.e. prepend
the assignment x=0).

Or, better: Use the fact that Sage's underlying language, both for
programming and interactive usage) is *Python* (with some syntactic sugar
to define polynomial rings or symbolic functions interactively). For
example:

  sage: [x for x in range(10) if (124+5*x)%2==0]
  [0, 2, 4, 6, 8]
  sage: for x in range(10):
  ....:     if (124+5*x)%2==0:
  ....:         print x,
  ....:         
  0 2 4 6 8

The first version creates a list of integers, that you can then use for
other purposes. The second version just prints the integers.

Best regards,
Simon


-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to