Advertisement
obernardovieira

AM2 1º desafio [Mathematica Challenge]

Feb 19th, 2015
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.34 KB | None | 0 0
  1. n = input('Qual o grau do polimonio?');
  2. a = zeros([1,n+1]);
  3.  
  4. for v = (n+1): -1: 1
  5.     input_text = sprintf('Introduza um valor para o "a" na ordem #%d:', v-1);
  6.     a(1,v) = input(input_text);
  7. end
  8.  
  9. x0 = input('Qual o valor de x?');
  10.  
  11. p = a(1,n+1);
  12.  
  13. for z = n:-1:1
  14.     p = (p * x0 + a(1,z));
  15. end
  16.  
  17. fprintf('O resultado é %d\n', p);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement