Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. -- Project Euler
  2. -- Problem 2
  3. -- Julio Toboso
  4.  
  5. with Ada.Text_IO; use Ada.Text_IO;
  6. with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
  7. procedure Euler_2 is
  8. Sum: Natural := 0;
  9. Limit : Natural := 4_000_000; -- 4 Million
  10. fib_1 : Natural := 0;
  11. fib_2 : Natural := 0;
  12. fib_3 : Natural := 1;
  13. begin
  14. loop
  15. fib_1 := fib_2;
  16. fib_2 := fib_3;
  17. fib_3 := fib_1 + fib_2;
  18. --Put(fib_3); -- To see that the series is correct. It is!
  19. exit when fib_3>Limit;
  20. if (fib_3 rem 2 = 0) then
  21. Sum := Sum + fib_3;
  22. end if;
  23. end loop;
  24. Put(sum);
  25. end Euler_2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement