--%>

State Fermat algorithm

The basic Fermat algorithm is as follows:

Assume that n is an odd positive integer. Set c = [√n] (`ceiling of √n '). Then we consider in turn the numbers

c2 - n; (c+1)2 - n; (c+2)2 - n.....

until a perfect square is found. If this occurs at the term (c+k)2 - n, then putting a = c+k we have

a2 - n = (c+k)2 - n = b2;

say, and then n = a2 - b2, as desired.

This process will terminate in the worst case when a = (n+1)/2, since

n = [(n+1)/2]2 - [(n-1)/2]2
 
In particular, the number of steps taken will be at worst

(n+1)/2 - [√n] +1 = O(n)

   Related Questions in Mathematics

  • Q : Numerical solution of PDE this

    this assignment contains two parts theoretical and coding the code has to be a new. old code and modified code will appear in the university website .

  • Q : Logic and math The homework is attached

    The homework is attached in the first two files, it's is related to Sider's book, which is "Logic for philosophy" I attached this book too, it's the third file.

  • Q : Global And Regional Economic Development

    The Pharmatec Group, a supplier of pharmaceutical equipment, systems and services, has its head office in London and primary production facilities in the US. The company also has a successful subsidiary in South Africa, which was established in 1990. Pharmatec South A

  • Q : Properties for polynomial Specify the

    Specify the important properties for the polynomial.

  • Q : Numerical Analysis Hi, I was wondering

    Hi, I was wondering if there is anyone who can perform numerical analysis and write a code when required. Thanks

  • Q : Containee problem For queries Q 1 and Q

    For queries Q1 and Q2, we say Q1 is containedin Q2, denoted Q1 C Q2, iff Q1(D) C Q2

  • Q : Abstract Algebra let a, b, c, d be

    let a, b, c, d be integers. Prove the following statements: (a) if a|b and b|c. (b) if a|b and ac|bd. (c) if d|a and d|b then d|(xa+yb) for any x, y EZ

  • Q : Elasticity of Demand For the demand

    For the demand function D(p)=410-0.2p(^2), find the maximum revenue.

  • Q : Theorem-Group is unique and has unique

    Let (G; o) be a group. Then the identity of the group is unique and each element of the group has a unique inverse.In this proof, we will argue completely formally, including all the parentheses and all the occurrences of the group operation o. As we proce

  • Q : Probability and Stochastic assignment

    Introduction to Probability and Stochastic Assignment 1: 1. Consider an experiment in which one of three boxes containing microchips is chosen at random and a microchip is randomly selected from the box.