Em Andamento

Project #3

A program that reads three numbers and returns the value

a^b mod n.

There is two parts to this

## Deliverables

1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.

2) Installation package that will install the software (in ready-to-run condition) on the platform(s) specified in this bid request.

3) Exclusive and complete copyrights to all work purchased. (No GPL, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site).

Devise a program that reads in three numbers, a, b , and n. It returns the value a^b mod n. (Recall that the modulo function gives the remainder of a ^b when divided by n). The program needs to multiplay a by itself b times and perform modulo arithmetic after each multiplication. You may assume that a and n are 16-bit values. Note that when a and b are large, the size of a^b may exceed 32-bit. Since n is a 16-bit value, the value of a^b mod n will be within 16-bit.

The mathematics behind: Note that

(c*d)mod n=[(c mod n) *(d mod n)] mod n. To compute a^b mod n, we can use the formula to first compute a^b-1 mod n, and then multiply the result with a, and then perform the modulo n operations to get the answer. A simple for loop should be enough.

Test the program with the following inputs:

1. A=1000, B=99999, N=1001

2. A=2, B=10000, N=10001

3. A= -10, B=19, N=37

Can you give the asymptotic of this procedure in terms of b?

Part B

Example: The bit pattern of the # b=41 is 101001. To compute, we write it as [(a mod n)*(a^8 mod n)*(a^32 mod n)] mod n ( using the formula discussed above). Notice that the ones in the binary representation of 41 occurs in the 1-bit, the 8-bit and the 32-bit. It remains to find a^8 mod n, and a^32 mod n. This can be accomplished by repeated squaring. It is easy to find a mod n. Now a^2 mod n = [(a mod n) *(a mod n)]mod n

a^4 mod n = [(a^2 mod n)*(a^2 mod n)]mod n

a^8 mod n = [(a^4 mod n)*(a^4 mod n)]mod n

a^16 mod n = [(a^8 mod n)*(a^8 mod n)]mod n

a^32 mod n = [(a^16 mod n)*(a^16 mod n)]mod n

only seven multipliacations are needed with this approach, compared to 31 in the procedure in part A.

Implement this strategy, and perform the same testing as in partA and Give asymptotic of this procedure in terms of b.

## Platform

Mircosoft Visual C++ 6.0

Habilidades: Programação C, Engenharia, MySQL, PHP, Arquitetura de software, Teste de Software

Ver mais: test modulo, strategy pattern example, strategy pattern, software strategy pattern, simple binary code, programming loop, pattern strategy, operations on binary, modulo test, modulo in c, mod programming, loop programming, for loop in c programming, for loop c programming, Find mathematics, find binary, c programming for loop, c programming find function, c modulo function, c modulo, c# functional programming project, bit representation, bit binary, binary explained easy, binary explained

Acerca do Empregador:
( 14 comentários ) United States

ID do Projeto: #3015523

Premiar a:

andreeamvw

See private message.

$21.25 USD em 6 dias
(7 Avaliações)
3.0

11 freelancers estão ofertando em média $28 para este trabalho

emilianbold

See private message.

$33.15 USD in 6 dias
(77 Comentários)
5.8
lmxvw

See private message.

$22.95 USD in 6 dias
(126 Comentários)
4.7
gchelidze

See private message.

$34 USD in 6 dias
(14 Comentários)
4.4
PDan

See private message.

$17 USD in 6 dias
(9 Comentários)
3.4
carefulwith

See private message.

$31.45 USD in 6 dias
(13 Comentários)
3.1
zetsoft

See private message.

$34 USD in 6 dias
(3 Comentários)
3.0
borninleningrad

See private message.

$25.5 USD in 6 dias
(5 Comentários)
2.9
costelus

See private message.

$25.5 USD in 6 dias
(20 Comentários)
2.8
homeworktutor

See private message.

$46.75 USD in 6 dias
(12 Comentários)
2.4
brainstormingvw

See private message.

$11.05 USD in 6 dias
(5 Comentários)
0.6