Click here to Skip to main content
14,739,661 members
Home » Discussions » C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Blum Blum Shub Pin
Member 149564756-Oct-20 11:32
MemberMember 149564756-Oct-20 11:32 
GeneralRe: Blum Blum Shub Pin
Richard Andrew x646-Oct-20 11:45
professionalRichard Andrew x646-Oct-20 11:45 
SuggestionRe: Blum Blum Shub Pin
David Crow6-Oct-20 17:05
MemberDavid Crow6-Oct-20 17:05 
GeneralRe: Blum Blum Shub Pin
Member 149564757-Oct-20 8:13
MemberMember 149564757-Oct-20 8:13 
AnswerRe: Blum Blum Shub Pin
David Crow7-Oct-20 8:31
MemberDavid Crow7-Oct-20 8:31 
GeneralRe: Blum Blum Shub Pin
Member 149564757-Oct-20 8:39
MemberMember 149564757-Oct-20 8:39 
GeneralRe: Blum Blum Shub Pin
David Crow7-Oct-20 8:55
MemberDavid Crow7-Oct-20 8:55 
AnswerRe: Blum Blum Shub Pin
Member 149564758-Oct-20 2:36
MemberMember 149564758-Oct-20 2:36 
Okay , so this is the final code that i have at the moment
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/*BLUM BLUM SHUB*/
int main ()
{

const int p = 347;
const int q = 351;
const unsigned long long int s = 12373273;
int N ;
printf("Introdu numarul de cifre aleatorii:");
scanf("%i", &N);
unsigned int i,M,x[N];
srand(time(NULL));

M=p*q;
i=0;
x[0]=s;
FILE *fp; //txt code
fp = fopen("file.txt", "w"); //txt code
for(i=1;i<=N;i++){
x[i]=rand()*(x[i-1]*x[i-1])%M;
}
for(i=1;i<=N;i++){
printf("%d\t",x[i]);
fprintf(fp, "%d ",x[i]); //txt code

}
system("PAUSE");
fclose(fp);//txt code

return 0;
}
It's working but i have one issue that i can't still solve , i need to put a maximal limit of the generated numbers at input , can anyone give me a clue how i can set x[i] a limit? I only found how to put a limit at rand but when it multiplies with function of BBS it exceeds the limit
GeneralRe: Blum Blum Shub Pin
Richard MacCutchan8-Oct-20 3:27
mveRichard MacCutchan8-Oct-20 3:27 
QuestionWritePrinter Fails to Print on Inkjet Printer Pin
sandford_j29-Sep-20 7:52
professionalsandford_j29-Sep-20 7:52 
QuestionRe: WritePrinter Fails to Print on Inkjet Printer Pin
David Crow29-Sep-20 17:44
MemberDavid Crow29-Sep-20 17:44 
AnswerRe: WritePrinter Fails to Print on Inkjet Printer Pin
sandford_j29-Sep-20 23:16
professionalsandford_j29-Sep-20 23:16 
QuestionRe: WritePrinter Fails to Print on Inkjet Printer Pin
David Crow30-Sep-20 3:01
MemberDavid Crow30-Sep-20 3:01 
AnswerRe: WritePrinter Fails to Print on Inkjet Printer Pin
sandford_j30-Sep-20 5:54
professionalsandford_j30-Sep-20 5:54 
AnswerRe: WritePrinter Fails to Print on Inkjet Printer Pin
Gerry Schmitz29-Sep-20 19:33
mveGerry Schmitz29-Sep-20 19:33 
GeneralRe: WritePrinter Fails to Print on Inkjet Printer Pin
sandford_j29-Sep-20 23:23
professionalsandford_j29-Sep-20 23:23 
AnswerRe: WritePrinter Fails to Print on Inkjet Printer Pin
mo149230-Sep-20 9:55
Membermo149230-Sep-20 9:55 
GeneralRe: WritePrinter Fails to Print on Inkjet Printer Pin
sandford_j30-Sep-20 13:05
professionalsandford_j30-Sep-20 13:05 
AnswerRe: WritePrinter Fails to Print on Inkjet Printer Pin
mo14921-Oct-20 2:18
Membermo14921-Oct-20 2:18 
GeneralRe: WritePrinter Fails to Print on Inkjet Printer Pin
sandford_j1-Oct-20 3:53
professionalsandford_j1-Oct-20 3:53 
QuestionCopying to ClipBoard By using SendInput, Failure....[Solved] Pin
EuiyongYun28-Sep-20 15:37
MemberEuiyongYun28-Sep-20 15:37 
AnswerRe: Copying to ClipBoard By using SendInput, Failure.... Pin
Victor Nijegorodov28-Sep-20 23:59
MemberVictor Nijegorodov28-Sep-20 23:59 
GeneralRe: Copying to ClipBoard By using SendInput, Failure.... Pin
EuiyongYun29-Sep-20 3:50
MemberEuiyongYun29-Sep-20 3:50 
GeneralRe: Copying to ClipBoard By using SendInput, Failure.... Pin
Victor Nijegorodov29-Sep-20 8:22
MemberVictor Nijegorodov29-Sep-20 8:22 
QuestionHow do I convert my C++ function pointer to a C function pointer? Pin
arnold_w28-Sep-20 6:06
Memberarnold_w28-Sep-20 6:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.