Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Code error in sagemath

My code in sagemath

    def bruteforce
    count = 0
     s = [0, 1, 2, 4, 8]
   s.each do |a|
s.each do |b|
  s.each do |c|
    s.each do |d|
      s.each do |e|
        if a+b+c+d+e == 8
          count += 1
          puts "#{count}.: #{a}+#{b}+#{c}+#{d}+#{e}"
          end
        end
      end
     end
    end
   end
  count
  end

but it was an error as below

  File "<ipython-input-1-87370adfacc9>", line 1
       def brutefor 
    SyntaxError: invalid syntax