Menu

Help - Maxima

2015-10-27
2015-10-27
  • daviodan daviodan

    What should I do in wxMaxima to display all natural numbers abc divisible by 7 and a+b+c=7? In SageMath, I use the commands:

    var('a,b,c')
    [100*a+10*b+c for a in range(1,10) for b in range(0,10) for c in range(0,10) if (100*a+10*b+c)%7==0 and a+b+c==7]
    
    133, 322, 511,700
    

    Thanks!

     
  • Andrej Vodopivec

    Maxima does not have list comprehensions, so it takes a little more code. You use create_listand sublistfunctions to get

    (%i1) sublist(
          create_list([a,b,c], a, 1, 9, b, 0, 9, c, 0, 9),
          lambda([l],
              is(l[1] + l[2] + l[3] = 7 and
                 mod(100*l[1] + 10*l[2] + l[3], 7) = 0)));
    (%o1) [[1,3,3],[3,2,2],[5,1,1],[7,0,0]]
    
     
  • daviodan daviodan

    Thank you very much!