Group Abstract Group Abstract

Message Boards Message Boards

0
|
6K Views
|
11 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Find semi-prime factors; program runs but doesn't compute

Posted 4 years ago

Clear x Clear pnp

    pnp = 85

    f[x] = ((x ^ 3  * pnp^2) / (pnp^2 + x) - x^3)

    For [x = 3, x < pnp/2, (x + 2), Print[x] ; 
     If[ {f[x] > 1}, {x = pnp} ]

different attempt

Clear x
Clear pnp

pnp = 85

f[x] = ((x ^ 3  * pnp^2) / (pnp^2 + x) - x^3)

x = 3; While [f[x] < 1, Print[x]; (x + 2)]
POSTED BY: Bobby Joe Snyder
11 Replies

Attached is a PDF that proves this work.

I hope it is clear enough. I need feedback because I am trying to write an article.

I know it has to be simplified but does anyone follow this?

Attachments:
POSTED BY: Bobby Joe Snyder

Thanks. I was so proud went I imported the 1st 1000 Primes from Wikipedia. I did know about that class library.

But what do you think about the rest.

POSTED BY: Bobby Joe Snyder
Posted 3 years ago

First 1000 primes

Array[Prime, 1000]
POSTED BY: Rohit Namjoshi
Attachments:
POSTED BY: Bobby Joe Snyder
Posted 4 years ago

Try

Clear[x,pnp,f];
pnp=85;
f[x_]:=x^4/(pnp^2+x);
For[x=3,x<pnp/2,x=x+2,
  If[f[x]<1,Print[x]]
]
POSTED BY: Bill Nelson
Posted 4 years ago

There is a missing ; and a ; that should be a , in the body of the For.

POSTED BY: Rohit Namjoshi

I hope this shows what I was trying to do. Syntax is not correct, I think. It just gives a recursive error.

Clear [x, pnp, f];

pnp = 85



For [x = 3, (x < (pnp/2)), (x = x + 2) ; 
 f[x] = x^4/(pnp^2 + x)
   If[f[x] < 1,
    Print[x]]
 ]

85

$RecursionLimit::reclim2: Recursion depth of 1024 exceeded during evaluation of If[f[5]<1,Print[x]].

$RecursionLimit::reclim2: Recursion depth of 1024 exceeded during evaluation of If[f[7]<1,Print[x]].

$RecursionLimit::reclim2: Recursion depth of 1024 exceeded during evaluation of If[f[9]<1,Print[x]].

General::stop: Further output of $RecursionLimit::reclim2 will be suppressed during this calculation.
POSTED BY: Bobby Joe Snyder

Clear [x, pnp, f];

pnp = 85
x = 3
f[x] = (x^3 - (x ^ 3  * pnp^2) / (pnp^2 + x))



Prime Factors fall where f[x] <1. Loop for x and check equation is less than one. Equation still doesn't run.
Here for a Semi-Prime of 5 the options are 3, 5, or 7 for the smallest Prime factor. 





Out[119]= 85

Out[120]= 3

Out[121]= 81/7228

In[122]:= N[81/7228]

Out[122]= 0.0112064



Out[115]= 85

Out[116]= 11

Out[117]= 14641/7236

In[123]:= N[14641/7236]

Out[123]= 2.02336





Out[111]= 85

Out[112]= 7

Out[113]= 2401/7232

In[124]:= N[2401/7232]

Out[124]= 0.331997



Out[107]= 85

Out[108]= 5

Out[109]= 125/1446

In[125]:= N[125/1446]

Out[125]= 0.0864454
POSTED BY: Bobby Joe Snyder

Yes the equation is always negative. But I only want x values greater than -1.

The SemiPrime smallest factor occurs near zero. I wanted to print the x values near zero.

And break at x values less than -1. It greatly eliminates the possible factors.

You have probably know this and are crunching numbers as I speak. I only ask you share the proper syntax of the program.

And thanks for all the programming help this far.

POSTED BY: Bobby Joe Snyder
Posted 4 years ago

There are several syntax errors.

Clear[x, pnp, f];

f[x_] := ((x^3*pnp^2)/(pnp^2 + x) - x^3)

I don't understand how f is going to compute semi-primes, its value is always negative so the loops never terminate.

Clear[pnp];
((x^3*pnp^2)/(pnp^2 + x) - x^3) // Simplify
(* -(x^4/(pnp^2 + x)) *)

Using built-in WL functions

Range[100] // AssociationMap[FactorInteger] // 
  Select[Total[#[[All, 2]]] == 2 &] // Keys
(* {4, 6, 9, 10, 14, 15, 21, 22, 25, 26, 33, 34, 35, 38, 39, 46, 49, 51,
55, 57, 58, 62, 65, 69, 74, 77, 82, 85, 86, 87, 91, 93, 94, 95} *)
POSTED BY: Updating Name

You are not resetting x. In particular, x+2 is not the same as x=x+2.

Also the use of Clear is not syntactically correct (it requires brackets e.g. Clear[x]).

POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard