Question

Project factoring need c++ code Because there are some numbers are very large, like 1316872907073608066468826571215294289 i...

Project factoring need c++ code

Because there are some numbers are very large, like 1316872907073608066468826571215294289 i really want to know how to read the file with this kind of numbers and store

For this project you will be factoring numbers, significantly smaller than the numbers used for RSA of course, but they will still be fairly large numbers. So large in fact that if you are using C++ you may not be able to natively represent these numbers. If you choose to use C++ for this project you will need to determine a way to store the number so that they can be used in your program. I would recommend the GNU Multiple Precision Library (GMP). Examine their webpage for download and use instructions.

In addition to factoring there will be some RSA messages given to you that you may choose to decipher, if you can factor the public key.

You will be given a list of many numbers and asked to factor them as quickly as you can. We only briefly talked about factoring integers in class with the naive algorithm. You will certainly have to find speed ups. There are some obvious speed ups, you don’t have to check every power of two, or every power of 3 or 5 or 7 etc this allows you to skip significantly many numbers. Using this you will be able to factor some of the earlier numbers in a reasonable amount of time.

There are other methods to factoring. All of the numbers in the given list are of the form pq for primes p and q. Meaning that once you have one factor you have both. This means that really all you need are prime numbers, if you can generate a list of large enough primes then you can factor all of these numbers.

Other methods of factoring include Pollard’s Rho, Pollard’s p−1, Quadratic Sieve. You may choose to look into some of these advanced options to help speed up your program, though if you decide not to that is fine as well.

Your work should include:

your program which reads numbers from a file and attempts to factor them

the list of numbers you are factoring

the output of your program in the form of

n=p∗q

for each n in the input file

the part of nums.txt: space splits each number

the file is too large I can't upload all, if you need plz left the email address
2605796209 2665827481 2727241729 2771188489 2835030001 2847758989 2913364501 2947078369 2981297941 3028508869 3034591009 3049979869 3095847409 3102585613 3104500681 3112189369 3167168281 3170523661 3174061717 3227199289 3258128161 3292343689 3299509573 3316369789 3383314189 3390678073 3410910409 3471883141 3533945809 3541966741 3549675937 3605282209 3613129213 3678058609 3686064013 3694086841 41446029193 42400845937 42442670821 43420447789 44076646753 44107007209 45123126481 45136546141 45294525253 46383710641 46906519489 47313779749 47418505357 48202589989 48266148793 48403775341 48558765529 49240451593 49347624901 49426792021 49436926573 49577203729 50258987461 50316828829 50349646933 50424523621 50462936941 50534274097 50575834357 50719343161 51365002009 51416833549 51509581597 51707129329 52257783793 52401858409 52515912613 52574733733 52723914409 52839107029 53448971581 53461677337 53545385293 54027422233 54056392861 54131813401 54180724909 54925816081 55024893793 55099462549 55574633353 56192853709 56211702949 56334049393 56560910977 56721402421 57110211853 57501432889 57571982173 57605156617 57735342529 57745514209 58529316661 58634894533 58734132973 58861969561 58900790929 59028990253 59710792261 59788260757 59818501333 59840754577 59948698081 60453354121 60857023393 61534005829 62085486193 62220617101 62776134229 62912768353 659212462561 670273603393 675064369117 675933082189 685715093737 689155888693 691297462249 691504953301 701536176193 705032381437 712816484953 716765373301 718405829821 718835176069 730973795281 732512263453 732897246253 733277922109 738697256569 742777903561 746577218209 747813671929 752540927773 753147874753 759889718449 762259130221 766861701157 770637079081 773336724961 777369373801 780569962993 783321054721 786310262821 787160732989 788464970857 788541416233 789922699681 794608781293 796326585793 796372965613 798059814301 798848808301 799385406397 800827374541 800856650749 802559408293 803050397389 804798260473 805218456337 807503261701 811748994181 812914654837 814719481717 818608014409 818759911093 820053051049 820084657177 820541966401 831176906761 833412873001 834712150501 836308942069 836794093573 839168494729 840423040333 845043330853 846919489573 849342599821 849814051789 850708706461 851163996517 851258628481 851561690101 852243253933 852612699409 853415139457 859082435689 860632469401 865005152761 868392659353 868442176081 868909408789 870320658073 870332366317 882466188361 884386902277 884541330793 886310353921 894381098029 897632687953 900179718469 903251155141 909113888257 910799928421 911132295937 912558954121 914205069913 925365020893 927419509213 928208819641 937912834681 940574160013 943243036849 944044483693 946099224601 946140444013 948199746841 948851358373 953508898417 953509746349 955228881601 956214477541 957939341173 959406519769 969364300969 970554490201 971112884857 971734986529 972864622921 989105521021 990146149801 991429879021 992301232357 994243058833 1002458690113 1005303164149 1007915849797 1009071652621 1009733974741 1011267927097 1019128053241 1020966403273 1048000590961 1059658702933 1071446501449 2827441619389 2892579068101 2916948245941 2950884291541 2973274730869 2984147711869 3006901937269 3016274273413 3018865562269 3041771823421 3085761971917 3089985417769 3101728176541 3102089631661 3138179629261 3142302578209 3154584486409 3161991210349 3173184527269 3187803236161 3207719973373 3214693665481 3224890433761 3227258519281 3234883007761 3249359950849 3292709110189 3296352241873 3298597714261 3302598938293 3337287762409 3341747410489 3348634348021

0 0
Add a comment Improve this question Transcribed image text
Answer #1

main.py

# Importing necssary libraries
from unRSA import *
import sys
import time

# Want to record the total time elapsed
start_time = time.time()

# Grabbing the user input from the command line
inInput = map(long,sys.argv[1:])
inInput = inInput[0]
print inInput

# Reading in the test file
with open("testlist.txt", 'r') as f:
    data = f.readlines()

# Here the text file data is mapped correctly
data = map(int,data)

# Calling the find factor function to find the first factor
p = findOneFactor(inInput)

# Dividing the number by the factor found above to find the second factor
q = inInput/p

# Printing and calculated the elapsed time
print "We have p = ",p," and q = ",q
elapsed_time = time.time()-start_time
print "The elapsed time is: "
print elapsed_time


unRSA.py


from math import sqrt

def findOneFactor(n):

    # Only have to check up to the sqrt(n)
    m = int(sqrt(n))

    # Checking 2 first before entering the loop
    if n % 2 == 0:
        return 2

    # starting the loop at 3
    i = 3

    while (i<=(m)):
        # checking if the factor has been found
        if n % i == 0:
            return i
        # We increment the loop by two to skip even numbers
        i = i+2

Add a comment
Know the answer?
Add Answer to:
Project factoring need c++ code Because there are some numbers are very large, like 1316872907073608066468826571215294289 i...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C++ program that will read a large .txt file and will find the highest...

    Write a C++ program that will read a large .txt file and will find the highest and lowest voltage, along with the associated time and ampere. The text file is large 1,000,000 rows of data, so speed is a factor. Per some of my own research it may be best to use mmap (If I have the fastest program I will receive a significant amount of extra credit)? Someone also told me that binary can be fast, but I have...

  • I am in C++ programming, I need help with this assignments. The answer in this assignments...

    I am in C++ programming, I need help with this assignments. The answer in this assignments when I look for it it doesn't work in my visual studios. Can you please help me? I hardly have C in the class, if I fail I will fail the whole class and repeat this class again.   The file named Random.txt contains a long list of random numbers. Download the file to your system, then write a program that opens the file, reads...

  • I need help in Python. This is a two step problem So I have the code...

    I need help in Python. This is a two step problem So I have the code down, but I am missing some requirements that I am stuck on. Also, I need help verifying the problem is correct.:) 7. Random Number File Writer Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500. The application should let the user specify how many random numbers the file...

  • Problem: Use the code I have provided to start writing a program that accepts a large...

    Problem: Use the code I have provided to start writing a program that accepts a large file as input (given to you) and takes all of these numbers and enters them into an array. Once all of the numbers are in your array your job is to sort them. You must use either the insertion or selection sort to accomplish this. Input: Each line of input will be one item to be added to your array. Output: Your output will...

  • JAVA please! Prime numbers are interesting numbers. A prime number is one that is only divisible...

    JAVA please! Prime numbers are interesting numbers. A prime number is one that is only divisible by 1 and itself. For hundreds of years mathematicians have looked for the largest prime number. In the year 1456 the largest known prime was 8191. By the year 1588 it was a 6-digit number: 131,071. The famous mathematician Leonhard Euler discovered the 10-digit number 2,147,483,647 in 1772. Over the years larger and larger primes have been found. There are contests to find the...

  • in c++ please HW09: Read/Write File Ints Now that we've had a taste of what file...

    in c++ please HW09: Read/Write File Ints Now that we've had a taste of what file I/O is all about, here's your chance to try it out on your own! You're to write a program that will prompt the user if he/she would like to read ints from a file (and have them displayed to stdout) or write ints to a file for safekeeping. If the user wishes to save a set of numbers, then the file nums.txt is opened...

  • i need help making this C++ code. Lab #2 Assignments: Numbers Class that translate whole dollar...

    i need help making this C++ code. Lab #2 Assignments: Numbers Class that translate whole dollar amounts in the range 0 through 9999 into an English description of the number. Numbers Class Design a class numbers that can be used to translate whole dollar amounts in the range 0 through 9999 into an English description of the number. For example, the number 713 would be translated into the string seven hundred thirteen, and 8203 would be translated into eight thousand...

  • Please write C++ code Description: As a senior software engineer, I would like to determine and...

    Please write C++ code Description: As a senior software engineer, I would like to determine and prove which sorting algorithm is the most efficient between quick sort, merge sort, and heap sort so that I can recommend it to the development team for inclusion in the code base of an upcoming code optimization project. Acceptance Criteria: Well documented, executable C++ source files including classes for each of the aforementioned sorting algorithms. In addition, each sorting algorithm class implementation should be...

  • I really need some help understaning how system verilog coding works in Cygwin I am a...

    I really need some help understaning how system verilog coding works in Cygwin I am a PC user, so I in order to have a linux version or an option to run commands I installed a program called Cygwin. This program currently allows me to run .cpp file and supposedly to run verilog (.v) and systemVerilog (.sv) file, but I am not able to or familiar with how to command call them from Cygwins terminal. I would also like to...

  • in c++ please Page 1 of 3 (PRO) Project Assignment Instructions Last Charged: 6/1/2020 Read and...

    in c++ please Page 1 of 3 (PRO) Project Assignment Instructions Last Charged: 6/1/2020 Read and follow the directions below carefully and perform the steps in the order listed. You will be solving one program as instructed and turning in your work electronically via an uploaded file within Eagle Online/Canvas and copy & paste the program to the Text Entry box as well. Make sure and check your work prior to uploading the assignment (NOTE: For Steps 1 & 2...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT