Recent

Author Topic: begginer - problem with function/program based on it. pascal  (Read 5470 times)

clara22

  • Newbie
  • Posts: 3
begginer - problem with function/program based on it. pascal
« on: November 05, 2014, 12:58:12 pm »
 Hello, i started working with pascal couple days ago ... but i cant figure out how to do this right .. i m learning by myself and i cant really figure this type of examples .. i did many programs/functios right but this one .. :( can maybe some one type this one for me with little description of process ? ..
Thanks a lot
 ..

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.
« Last Edit: November 05, 2014, 01:06:09 pm by clara22 »

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7801
Re: begginer - problem with function/program based on it.
« Reply #1 on: November 05, 2014, 01:05:42 pm »
Hello, i started working with pascal couple days ago ... but i cant figure out how to do this right .. i m learning by myself and i cant really figure this type of examples .. i did many programs/functios right but this one .. :( can maybe some one type this one for me with little description of process ? ..

So how far did you get? Did you translate the example into pseudo code? Most people won't do homework assignments for you, but if you show you have put in some effort you might get help.

Bart

  • Hero Member
  • *****
  • Posts: 3588
    • Bart en Mariska's Webstek
Re: begginer - problem with function/program based on it. pascal
« Reply #2 on: November 05, 2014, 01:28:18 pm »
By pseudocode marcov means that you write down an algorithm in something that is not real code yet, like (fictitious example):
count all persons
count all apples
while apples > persons do
begin
  give apple to each person
  count all apples
end
remainder = apples left
eat remainder

Bart

clara22

  • Newbie
  • Posts: 3
Re: begginer - problem with function/program based on it. pascal
« Reply #3 on: November 06, 2014, 05:05:44 pm »
Sorry :p i have been working with that program just for like 4 days i have no idea how to write down program with function i have been learning all by my self .. so i m kind of lost that why i was looking for little description on a side . . for now i have this but its ... sorry but i cant send picture . Some error shows up that telling me to contact administrator.. never mind i will try elsewhere but anyway thanks for your time :)

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: begginer - problem with function/program based on it. pascal
« Reply #4 on: November 06, 2014, 05:15:06 pm »
Don't send a picture please, copy and paste your source code.

Then put them between [ code ] [ /code ] tags (remove spaces please) so the forum software does not mess up the contents.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

clara22

  • Newbie
  • Posts: 3
Re: begginer - problem with function/program based on it. pascal
« Reply #5 on: November 06, 2014, 05:52:02 pm »
No worries i wont .. i will try easier things for now its too much for me to handle by now thanks maybe i will chceck this page when i get some experience.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: begginer - problem with function/program based on it. pascal
« Reply #6 on: November 06, 2014, 06:09:36 pm »
Good luck!
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: begginer - problem with function/program based on it. pascal
« Reply #7 on: November 09, 2014, 09:09:13 pm »
@clara22

If you can donate $10, I could show you the code (since you have said that you are willing to pay).
« Last Edit: November 09, 2014, 09:14:18 pm by typo »

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: begginer - problem with function/program based on it. pascal
« Reply #8 on: November 09, 2014, 09:51:02 pm »
Here is the code:

Code: [Select]
{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.}
var
  i :integer;
  n1, n2 :integer;
  s :string;
  IsFair :boolean;
begin
  IsFair := False;
  for i := 1 to Length(Edit1.Text) do
  begin
    if TryStrtoInt(Edit1.Text, n1) and TryStrtoInt(Edit1.Text[i], n2) then
    begin
      IsFair := True;
      if n1 mod n2 <> 0  then
      begin
        IsFair := False;
        Break;
      end;
    end;
  end;
  if IsFair then
    ShowMessage('Is Fair')
  else
    ShowMessage('Is Not Fair');
end;         

Bart

  • Hero Member
  • *****
  • Posts: 3588
    • Bart en Mariska's Webstek
Re: begginer - problem with function/program based on it. pascal
« Reply #9 on: November 09, 2014, 10:56:40 pm »
Hey, another person with the same homework/assignment  O:-)

Bart

Leledumbo

  • Hero Member
  • *****
  • Posts: 8139
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: begginer - problem with function/program based on it. pascal
« Reply #10 on: November 10, 2014, 07:40:27 am »
Hey, another person with the same homework/assignment  O:-)

Bart
Guessing the name, could it be the girlfriend of the guy from the previous thread?

CM630

  • Hero Member
  • *****
  • Posts: 872
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: begginer - problem with function/program based on it. pascal
« Reply #11 on: November 10, 2014, 07:57:29 am »
Hey, another person with the same homework/assignment  O:-)

Bart
Guessing the name, could it be the girlfriend of the guy from the previous thread?
I'd rather bet on s.o. using a female name to get more attention on a dominantly male forum  >:D
Лазар 2,0,6;W7 64bit or XP 32bit;FPC3,2,0;rev 62129

Bart

  • Hero Member
  • *****
  • Posts: 3588
    • Bart en Mariska's Webstek
Re: begginer - problem with function/program based on it. pascal
« Reply #12 on: November 10, 2014, 06:26:39 pm »
Hey, another person with the same homework/assignment  O:-)

Bart
Guessing the name, could it be the girlfriend of the guy from the previous thread?

That would be hilarious, but it's rather unlikely, since that dude already paid big bucks ($28) to get it solved for his g.f.

Bart

rvk

  • Hero Member
  • *****
  • Posts: 3861
Re: begginer - problem with function/program based on it. pascal
« Reply #13 on: November 10, 2014, 08:14:11 pm »
Guessing the name, could it be the girlfriend of the guy from the previous thread?
That would be hilarious, but it's rather unlikely, since that dude already paid big bucks ($28) to get it solved for his g.f.
It's highly likely because this topic started on November 05th and the other topic (with the paid solution, which worked fine b.t.w.) was started on November 7th.

(The solution he mentioned at the start of the topic worked correctly it just wasn't a separate function as stated in the assignment. Plus he thought it gave weird numbers which according to me/us the numbers where correct.)
« Last Edit: November 10, 2014, 08:18:13 pm by rvk »

eny

  • Hero Member
  • *****
  • Posts: 1588
All posts based on: Win10 (Win64); Lazarus 1.8.0 'stable' (#56594 win64) unless specified otherwise...