Dean 1 #1 Posted July 20, 2010 (edited) http://pt.wikipedia.org/wiki/Conjectura_de_Goldbach Todo inteiro par maior que 2 pode ser escrito como a soma de 2 números primos. No curso de iniciação científica que eu faço na Unicamp, a gente tava comentando sobre esse problema,até ganhamos um livro sobre ele.Então eu resolvi fazer um programinha que demonstra a validade da conjectura até um número natural n. function crivo(t) d = {} function isPrimo(n) if (n == 1) then return false end if (n == 2) then return true end f = math.floor(n/2) for i = 2,f do if n % i == 0 then return false end end return true end for i = 1,t do if isPrimo(i) then table.insert(d,i) end end return d end function goldbach(n) if n < 4 then return print("N deve ser maior que 4!") end primos = crivo(n) for i = 4,n,2 do for t,v in pairs(primos) do local y = inTable(primos,(i - v)) if y then print(i.." = "..y.." + "..v) break end end end end function inTable(t,v) for x,y in pairs(t) do if y == v then return y end end return false end goldbach(1000) Pog powered Edited January 23, 2011 by Mickfern Share this post Link to post Share on other sites
nogareD 0 #2 Posted July 20, 2010 for i = 4,n,2 do i=4,n,2? nao entendi Share this post Link to post Share on other sites
Sinister 0 #3 Posted July 20, 2010 i=4,n,2 i vai de 4 a n, 2 é o complemento Share this post Link to post Share on other sites
Roku 0 #4 Posted July 20, 2010 gostei, aprendi bem com isso legal fazer funções matematicas script legal, vo da uma estudada Share this post Link to post Share on other sites