Finding factors of number and factoring a polynomial (Lua) -


i'm attempting program lua syntax (i have experience it) find factors of , number , possibly factor input polynomial. i'm not sure if has done factoring learned doing "multiply to" , "add to"/"x-box" method. it'd interesting draw out method in lua (see picture attached)basically draw a) , display answer. if not draw, i'd use print command.

i program have 2 parameters: 1 number determine prime factors , other polynomial input (like a, b , c values ax^2+bx+c) factored. may attempt perfect squares , difference of squares.

i'd guidance in , i'm in no way expecting full working program. in advance.

you can make for chunk loop function this

function factor(val) val=math.floor(val) found={} rev={os.time()*4} halt=0 lasti=0 lastm=0 m=1,val     if halt==1         break     end     if lasti == m         halt=1         break     else     i=0,val         if m*i == val             print(m.."*"..i.."="..val)             table.insert(found,m.."*"..i)             table.insert(rev,i.."*"..m)             lasti=m             else         end     end end end return found end 

it return posable factors downside run wards it's not problem.

usage example:factor(6) returns:{1*6,2*3,3*2,6*1}.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -