Click here to Skip to main content
15,900,378 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Blum Blum Shub Pin
Member 149564756-Oct-20 10:32
Member 149564756-Oct-20 10:32 
GeneralRe: Blum Blum Shub Pin
Richard Andrew x646-Oct-20 10:45
professionalRichard Andrew x646-Oct-20 10:45 
SuggestionRe: Blum Blum Shub Pin
David Crow6-Oct-20 16:05
David Crow6-Oct-20 16:05 
GeneralRe: Blum Blum Shub Pin
Member 149564757-Oct-20 7:13
Member 149564757-Oct-20 7:13 
AnswerRe: Blum Blum Shub Pin
David Crow7-Oct-20 7:31
David Crow7-Oct-20 7:31 
GeneralRe: Blum Blum Shub Pin
Member 149564757-Oct-20 7:39
Member 149564757-Oct-20 7:39 
GeneralRe: Blum Blum Shub Pin
David Crow7-Oct-20 7:55
David Crow7-Oct-20 7:55 
AnswerRe: Blum Blum Shub Pin
Member 149564758-Oct-20 1:36
Member 149564758-Oct-20 1: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 2:27
mveRichard MacCutchan8-Oct-20 2:27 
QuestionWritePrinter Fails to Print on Inkjet Printer Pin
sandford_j29-Sep-20 6:52
professionalsandford_j29-Sep-20 6:52 
QuestionRe: WritePrinter Fails to Print on Inkjet Printer Pin
David Crow29-Sep-20 16:44
David Crow29-Sep-20 16:44 
AnswerRe: WritePrinter Fails to Print on Inkjet Printer Pin
sandford_j29-Sep-20 22:16
professionalsandford_j29-Sep-20 22:16 
QuestionRe: WritePrinter Fails to Print on Inkjet Printer Pin
David Crow30-Sep-20 2:01
David Crow30-Sep-20 2:01 
AnswerRe: WritePrinter Fails to Print on Inkjet Printer Pin
sandford_j30-Sep-20 4:54
professionalsandford_j30-Sep-20 4:54 
AnswerRe: WritePrinter Fails to Print on Inkjet Printer Pin
Gerry Schmitz29-Sep-20 18:33
mveGerry Schmitz29-Sep-20 18:33 
GeneralRe: WritePrinter Fails to Print on Inkjet Printer Pin
sandford_j29-Sep-20 22:23
professionalsandford_j29-Sep-20 22:23 
AnswerRe: WritePrinter Fails to Print on Inkjet Printer Pin
mo149230-Sep-20 8:55
mo149230-Sep-20 8:55 
GeneralRe: WritePrinter Fails to Print on Inkjet Printer Pin
sandford_j30-Sep-20 12:05
professionalsandford_j30-Sep-20 12:05 
AnswerRe: WritePrinter Fails to Print on Inkjet Printer Pin
mo14921-Oct-20 1:18
mo14921-Oct-20 1:18 
GeneralRe: WritePrinter Fails to Print on Inkjet Printer Pin
sandford_j1-Oct-20 2:53
professionalsandford_j1-Oct-20 2:53 
QuestionCopying to ClipBoard By using SendInput, Failure....[Solved] Pin
EuiyongYun28-Sep-20 14:37
EuiyongYun28-Sep-20 14:37 
AnswerRe: Copying to ClipBoard By using SendInput, Failure.... Pin
Victor Nijegorodov28-Sep-20 22:59
Victor Nijegorodov28-Sep-20 22:59 
GeneralRe: Copying to ClipBoard By using SendInput, Failure.... Pin
EuiyongYun29-Sep-20 2:50
EuiyongYun29-Sep-20 2:50 
GeneralRe: Copying to ClipBoard By using SendInput, Failure.... Pin
Victor Nijegorodov29-Sep-20 7:22
Victor Nijegorodov29-Sep-20 7:22 
QuestionHow do I convert my C++ function pointer to a C function pointer? Pin
arnold_w28-Sep-20 5:06
arnold_w28-Sep-20 5: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.