Lazarus
Free Pascal => General => Topic started by: burak on November 07, 2014, 03:34:41 pm
-
Hello, i have written program like this ...
Program j;
var f, g,a, b, c, m, i:integer;
begin
read1n (f, g)
for i:=2 to g do
for a:=1 to 9 do
for b:=1 to 9 do
for c:=1 to 9 do
begin
m:a*100+b*10+c;
if (m mod a=0) and
(m mod b=0) and
(m mod c=0) then
write1n(' ', m);
end;
read1n;
end.
But its not working right ... u can run it but it will find weird numbers :))
Can anyone help me out ??
May some one check the program and correct it please ? :)
-
A positive integer N is called a " fair " if it is divisible by each of its digits. For example, the number 132 is fair , because it is divisible by 1 , 3 and 2. In contrast the number 123 is not fair, since , although divisible by 1 and 3 but not divisible by 2. Write a function that determines whether a fair number N ( N the parameter is a function). Next, write a program which uses this function finds and displays all the honest numbers range from A to B, including ( value of A, B will be awarded to the entry of the program - are positive integers from the range of data type integer.
-
First describe the steps needed to accomplish this task.
Here are the first few steps (dont worry about the code yet):
- get all the digits out of a number (e.g. 1231 -> 1 and 2 and 3)
- try if the number can be divided by all of the digits (what to do if a number contains a zero?)
This basically describes the algorithm for determining if a number is "fair"
Do the same (describing the steps) for the procedure that determines that for a range of numbers from A to B.
After that translate each step into Pascal code, you may want to look into sets (and the operator in), div, mod.
Try to compile the code, show us the code and any errors in it.
At that stage we will help.
We won't do your assigment for you.
Bart
-
Well, i have only like a day left so i have to ask if there is any chance to pay for the program ?? If yes how much it may cost and how can i pay :p
-
Well, i have only like a day left
Well, start then.
It is a trivial task.
Break down the problem in steps.
Post it here, get feedback.
Write code.
Post it her, get feedback.
Should not take you more than a few hours.
so i have to ask if there is any chance to pay for the program ?? If yes how much it may cost and how can i pay :p
I guess this is either a joke, or you are not willing to learn anything from you assignement at all.
If the latter is the case, I will do it for you if you promise me two things:
- Never do any programming in your life ever!
- Never work in healthcare, given your current attitude towards learning. You will kill people.
I require €500 to be paid to the Lazarus PayPal account (and proof that it has been paid, since I don't have access to that account.
Bart
-
@Bart: Excellent answer!
-
@bart Legend!
-
What is wrong with education? Does it emphasize on grade too much as opposed to knowledge gain such that we have to deal with this kind of student? It happens nearly everywhere and I'm SICK of it. A grade should be able to represent the actual knowledge and skill of the owner. If your grade is F and you can barely understand what you code, then that's fair. But if you have A while you don't even understand your code, WHAT THE FUCK IS THAT???!!! I'm glad companies nowadays are not using GPA blindly to select for employees. Technical test has a much bigger portion now. A graduate with good or even great GPA but unemployed? It's YOUR fault!
-
I attached a working project.
I dare you to submit it to your teacher though, it's complexity will be noticably above your skills-level.
Amongs others it deals with numbers of arbitrary size (up to 2000000000 digitis long), and adjusts for quantum fluctuations in computer hardware.
Just check it out.
Here's how to compile it:
C:\Users\Bart\LazarusProjecten\ConsoleProjecten\fair>fpc longfair.lpr
Free Pascal Compiler version 2.6.4 [2014/03/06] for i386
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling longfair.lpr
Compiling ncalc.pp
Compiling boolfactory.pp
boolfactory.pp(46,14) Note: Virtual method "TCustomBoolFactory.ToString:AnsiString;" has a lower visibility (private) than parent class TObject (public)
Compiling expressions.pp
expressions.pp(42,28) Warning: Constructing a class "TBoolFactory" with abstract method "AsString"
expressions.pp(55,28) Warning: Constructing a class "TBoolFactory" with abstract method "AsString"
ncalc.inc(458,3) Note: Local variable "i" not used
ncalc.inc(458,6) Note: Local variable "LucMin1" not used
ncalc.inc(458,15) Note: Local variable "LucMin2" not used
ncalcdiv.inc(82,8) Note: Local variable "_N1" is assigned but never used
ncalcdiv.inc(183,8) Note: Local variable "ADiv" is assigned but never used
ncalc.inc(1262,3) Note: Local variable "RomanValues" not used
Linking longfair.exe
3932 lines compiled, 3.1 sec , 154448 bytes code, 46556 bytes data
2 warning(s) issued
7 note(s) issued
And heres how to run it (check the output below to see that it works):
C:\Users\Bart\LazarusProjecten\ConsoleProjecten\fair>longfair 10 256
Listing all "fair" numbers from 10 to 256
Found a fair number: 11
Found a fair number: 12
Found a fair number: 15
Found a fair number: 22
Found a fair number: 24
Found a fair number: 33
Found a fair number: 36
Found a fair number: 44
Found a fair number: 48
Found a fair number: 55
Found a fair number: 66
Found a fair number: 77
Found a fair number: 88
Found a fair number: 99
Found a fair number: 111
Found a fair number: 112
Found a fair number: 115
Found a fair number: 122
Found a fair number: 124
Found a fair number: 126
Found a fair number: 128
Found a fair number: 132
Found a fair number: 135
Found a fair number: 144
Found a fair number: 155
Found a fair number: 162
Found a fair number: 168
Found a fair number: 175
Found a fair number: 184
Found a fair number: 212
Found a fair number: 216
Found a fair number: 222
Found a fair number: 224
Found a fair number: 244
Found a fair number: 248
I'm awaiting the €500 ...
Bart
-
Ah, yes, that's powerful code. I recognize it from your earlier posts.
Let's see whether the 500€ is paid.
-
I attached a working project.
I dare you to submit it to your teacher though, it's complexity will be noticably above your skills-level.
Amongs others it deals with numbers of arbitrary size (up to 2000000000 digitis long), and adjusts for quantum fluctuations in computer hardware.
Just check it out.
Briliant! :P
-
Well, thanks for your hateful speech ... i m really ashamed that i m trying solve this example for my gf becouse she have to ride to school fucking 3 hours per day only there and then back. She really have time to solve pascal when nobody i know use that at work or anywhere thanks for your ironic or should i say phatetic code rly .. i already paid 28$ for it and yes i feel so bad for doing so .. "haha". I study psychology myself so yes i wont ever be using this at real life thanks for advice mr. Have a nice day anyway ... bye.
-
Rhetorical question (we already know the answer): do the words "cheating" and "academic integrity" mean anything to you?
-
... thanks for your ironic or should i say phatetic code rly
First of all. You never even tried to answer my first questions, which were in fact a well meant attempt to help you solve this problem.
Second: my posted code does the job perfectly well, and it does that for very large numbers (for which most programming languages do not have a native type).
You might have learnt from studying the code that the essence of the program was:
- Make a function that extracts all digits from a given number
- Make a function that divides a given number by all of it's digits: if either some digit is 0, or the division by a digit has a remainder then the number is not fair
- Make a procedure that runs this code on a range of numbers (Start to Stop)
- Make a procedure that asks the user what Start and Stop should be, so the program is flexible
- Stick all these pieces together
Wether or not this code is efficient is up for debate.
...to solve pascal when nobody i know use that at work or anywhere...
This does not really matter now, does it?
All programming starts with analyzing the problem and breaking it down into small pieces.
Or are you telling me you (or your gf) could have written this code in C, Basic, Java, PHP or any other programming language, but just not in Pascal?
.. i already paid 28$ for it and yes i feel so bad for doing so .. "haha". I study psychology myself so yes i wont ever be using this at real life ...
Well, your unwillingness to analyse a problem, your stinginess when it comes to presenting the truth, your willingness to defraude, your inability to accept sincere help when offered to you and your inability to distinguish said offer from the irony that came with it, makes me pitty the patient that has the misfortune to fall into your hands.
I have no doubt however that you will have a glorious career, you seem to have all the right competencies for it.
Bart
-
For a psychology student, he doesn't seem to have the attitude of a psychologist. Nevermind, programming world doesn't need people like that. Despite he means to help, he actually kills his girlfriend's future. I think GPA should be stripped out of a CV selection. Links to cloud repositories where we can analyze code commits along with resulting application is a better way to select good programmers.
-
Somebody spended too much time at forum. Wake up .. ppl around you have other things to take care of then pascal and having academic integrity. I dont rly ment to offend anybody i was just looking for some help nwm. Happy lifes guys i dont have any more time to waste here bb
-
Then why do you force on getting what your girlfriend doesn't deserve? If your education forces you to spend a lot of time working on assignments, then that's the risk you have to take. If you can't make it work to perfect 100, then submit what you have done best. What you get is what you have struggled, not what other people have. You can get help, if you do it properly. We will help people who show their effort, and is willing to improve based on clues and hints we give (how do you think we answer other people questions including homeworks/assignments but not on you/your girlfriend's?) . You don't have any of what I mentioned...
-
For a psychology student you would have thought the 3 hour girlfriend trip would have been mentioned earlier!
Anyway I would like to take this opportunity to thank the hero members, my coding skills are not great by any stretch of the imagination, and I’ve used this forum everyday for 5 or so years now, and found it to be a rich source for information and its members to be very helpful indeed.
@Bart thank you for posting the code, always useful to learn from well written code.
-
But its not working right ... u can run it but it will find weird numbers :))
Not that it matters at this point... but what where the "weird numbers"? When I run your code from your first post (after fixing some typing errors) I get the following numbers:
111
112
115
122
124
126
128
132
...
etc
Weren't these the exact numbers Bart's program came up with? (With a few exceptions like <100 etc)
(This topic became somewhat off topic because you didn't explain exactly what went wrong with your own code and, well, finally asking for somebody to do it for money on an enthusiast-site isn't the smartest move because here we would be all too happy to just help you with your own code.)
-
@Bart thank you for posting the code, always useful to learn from well written code.
Better take a look at attached version then...
It's a little more efficient (but supports only integers).
Bart
-
... i already paid 28$ for it ...
Hmm. we should open a separate thread on the forum, helping people solve such easy academic tasks for a fee.
That serves two useful purposes:
* the reliable source of income to pay for hardware/hosting and other community needs
* students seeking for help won't get into trouble or get a wrong solution
Solution provider gets its own share - 90% of the sum.
burak pretty much specified an average price for a solution $10 - $30.
-
I think it is a good idea.
-
Hmm. we should open a separate thread on the forum, helping people solve such easy academic tasks for a fee.
That serves two useful purposes:
* the reliable source of income to pay for hardware/hosting and other community needs
* students seeking for help won't get into trouble or get a wrong solution
Solution provider gets its own share - 90% of the sum.
burak pretty much specified an average price for a solution $10 - $30.
Hmm... if it's down to business, then I agree.
-
Hmm... if it's down to business, then I agree.
it really should be the business. ...and we (as a community) kinda failed on this opportunity.
So, however read the thread and see a similar post the next time lets a be more business-like the next time.
"Yes, we can debug your code, but for a gratitude" or so...
The money could be spent for sponsoring bounties for outstanding items or paying the services that we use.
-
Maybe a "Pay for a Task" easy to find button on the forum or website.
- Describe the task.
- Make your offer.
- Choose the best answer.
It is necessary to define whether the payer will pay before or after the answer.
-
like this (http://forum.lazarus.freepascal.org/index.php/topic,26407.0.html) :)
-
Who wants to volunteer? Real business usually end up in PM, should we let it open to the forum?
-
should we let it open to the forum?
I think so.
-
Would the payer donate to the project? How would be this payment verified?
-
Seems fair numbers are in high demand nowadays: http://forum.lazarus.freepascal.org/index.php/topic,26365.0/topicseen.html
-
Yes. I would like to know how to receive the money to the project, through a donation. So how to verify this donation?
-
Yes. I would like to know how to receive the money to the project, through a donation. So how to verify this donation?
AFAIR we have a PayPal account, but I don't know the name nor the link nor the maintainer.