Not Yet Answered # needed recursion help

murschech 11 harshchandra -3 harshchandra -3 Discussion Starter fopah Asif_NSU 25

0

i am trying to make a program that displays to the screen the prime factors of a given number. i have it all the way to the prime number checking i dont quite understand how to extract the prime numbers any help would be much appreciated

I'm not sure I know what you mean by having it "all the way to prime number checking". I'll guess that you mean that you know how to check whether the given number is a prime or not. If you find that it's a prime, then you're finished. Suppose the given number is N and you've found that it's not a prime. You've found this out, I guess, by finding a number d such that d is a divisor of N. (i.e., N % d == 0). The apply your method to N/d.

0

A prime no is the one which either divides by itself or by 1 .....So u create a loop from 1 to that number and keep on counting how many times it exactly gets divides ...if it comes to 2 then u can say it is prime number....the code can look like this.....

scanf("%d",&n);

for(i=1;i<=n;i++)

{ if((i % n) == 0)

count++;

}

if(count==2)

printf("It is prime no");

0

Hey i think i misread the question......U want Prime factors of a no or U want to display prime number

0

i am not supposed to use any loops. it was supposed to go like i if i gave it 10 it would give me 2*5 as an output something like that

0

Ha ha! There are so many ways to do it. The easiest process is to try divide the number with every number less than (or half of it) and see if it has the remainder 0. If it does then check if the number u r dividing with is a prime number or not. This is the easiest process although is not efficient for large numbers. For other ways about doing this prime factorization go to mathworld

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"

Here is the sample output that I ...

Hello All ...

Iam Getting An Error With try to excecute the stored procedure .

I have Have Sql database , the stored procedure like so :

```
USE [MPRS]
GO
/****** Object: StoredProcedure [dbo].[Search_Licenses_By_Number] Script Date: 26-Nov-16 8:06:52 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE ...
```

I don’t want at this stage work on a big separate project as I've already got plenty ...